Using Golang
Golang alternative using webview (modern, simple and lightweigth).
Install
go get github.com/webview/webviewSource Code
package main
import (
"fmt"
"net/url"
"os"
"path/filepath"
"github.com/webview/webview"
)
type GoFileClass struct{}
func (g GoFileClass) SayHello(name string) {
fmt.Println("Hello, ", name)
}
func main() {
debug := false
w := webview.New(debug)
defer w.Destroy()
// Window Title
w.SetTitle("My Application")
// Window Size
w.SetSize(800, 600, webview.HintNone)
// Path to HTML file
cwd, _ := os.Getwd()
htmlPath := filepath.Join(cwd, "index.html")
u := url.URL{Scheme: "file", Path: htmlPath}
// Bind Go ↔ JavaScript
w.Bind("GoFileClass", GoFileClass{})
// LoadHTML
w.Navigate(u.String())
// Execute
w.Run()
}Bind JS → Go
Add in you index.html:
<button onclick="GoFileClass.SayHello('World')">Say Hello</button>