사용할 라이브러리는 Lorca
https://github.com/zserge/lorca
홈페이지에서 가져온 Features:
- Pure Go library (no cgo) with a very simple API
- Small application size (normally 5-10MB)
- Best of both worlds - the whole power of HTML/CSS to make your UI look
good, combined with Go performance and ease of development
- Expose Go functions/methods and call them from JavaScript
- Call arbitrary JavaScript code from Go
- Asynchronous flow between UI and main app in both languages (async/await and Goroutines)
- Supports loading web UI from the local web server or via data URL
- Supports testing your app with the UI in the headless mode
- Supports multiple app windows
- Supports packaging and branding (e.g. custom app icons). Packaging for all
three OS can be done on a single machine using GOOS and GOARCH variables.
샘플 코드:
ui, _ := lorca.New("", "", 480, 320)
defer ui.Close()
// Bind Go function to be available in JS. Go function may be long-running and
// blocking - in JS it's represented with a Promise.
ui.Bind("add", func(a, b int) int { return a + b })
// Call JS function from Go. Functions may be asynchronous, i.e. return promises
n := ui.Eval(`Math.random()`).Float()
fmt.Println(n)
// Call JS that calls Go and so on and so on...
m := ui.Eval(`add(2, 3)`).Int()
fmt.Println(m)
// Wait for the browser window to be closed
<-ui.Done()