Go bindings for webview/webview using purego, with no CGO, and prebuilt native libraries for Windows, macOS, and Linux.
- No CGO
- Cross-platform (Windows, macOS, Linux)
- Prebuilt dynamic libraries included
- Bind Go functions to JavaScript
- Fully embeddable in pure Go projects
package main
import (
"github.com/abemedia/go-webview"
_ "github.com/abemedia/go-webview/embedded" // embed native library
)
func main() {
w := webview.New(true)
w.SetTitle("Greetings")
w.SetSize(480, 320, webview.HintNone)
w.SetHtml("Hello World!")
w.Run()
w.Destroy()
}
See ./examples/bind for an example binding Go functions to JavaScript.
When building Windows apps, set the following flag: -ldflags="-H windowsgui"
.
go build -ldflags="-H windowsgui" .
This package requires native WebView libraries per-platform. To embed them in your app import the embedded
package.
import _ "github.com/abemedia/go-webview/embedded"
Or you can ship your application with .dll
, .so
, or .dylib
files.
Ensure these are discoverable at runtime by placing them in the same folder as your executable.
For MacOS .app
bundles, place the .dylib
file into the Frameworks
folder.
See the embedded
folder for pre-built libraries you can ship with your application.
- webview/webview — core native UI library
- purego — pure-Go
dlopen
magic