project

Glaze

Desktop WebView binding for Go, pure-Go and without CGO, calling the system WebView directly through purego, with no native library bundled.

1 related articles GitHub

Glaze is a Go binding for desktop WebViews. It’s a pure-Go port of webview/webview on top of purego, with no cgo and no native library bundled in.

The project started as a fork of go-webview but has diverged enough to live as a separate codebase with its own goals.

The reason for avoiding cgo: dragging a C toolchain into a Go project just to open a window with HTML breaks too much of what I like about the Go ecosystem – easy cross-compilation, reproducible builds, go install that works for whoever clones the repo. The old version embedded the compiled C++ webview library and extracted it to disk at runtime. Now each backend calls, through purego, the WebView the operating system already ships: WKWebView on macOS, WebKitGTK on Linux, WebView2 (COM) on Windows. No native library in the binary.

What you need at runtime is that WebView present: nothing extra on macOS, a system WebKitGTK on Linux (GTK4 libwebkitgtk-6.0 or GTK3 libwebkit2gtk-4.1/4.0, detected at runtime), and the Edge WebView2 Runtime on Windows (preinstalled on current 10/11).

What sits outside the core:

  • BindMethods – registers every exported method on a Go struct as a JavaScript function, with snake_case names. Useful when you have a service object and want to expose a consistent API without writing one Bind call per method.
  • RenderHTML – renders a Go html/template for use with SetHtml. For when you want server-style template rendering without running a server.
  • AppWindow – wraps an http.Handler in a native window backed by a local HTTP server. macOS and Linux default to Unix sockets, Windows uses TCP loopback. The shortest path from an existing HTTP app to a desktop app without rewriting routes, templates, or assets.

Works on Windows, macOS, and Linux. Examples in the repository include Game of Life, Mandelbrot, Doom Fire, Raycasting, and a REPL for Filo.