Most Go developers reach for frameworks or browser servers when they need a user interface, but desktop WebView tools now offer a lighter alternative. Glaze, a fresh open-source project, lets you open native windows using the operating system’s built-in WebView—no CGo, no bundled libraries, and no heavy GUI framework required.
Why skip CGo and native helpers?
Many Go projects that need a window fall back to CGo or large desktop libraries, adding complexity to builds and deployments. Glaze was designed to avoid that path entirely. Instead of compiling C code or shipping platform-specific binaries, Glaze calls the system WebView directly from pure Go using purego, an interface that bridges Go and C APIs without a compiler.
- macOS users get WKWebView through CoreGraphics.
- Linux users receive WebKitGTK through GTK bindings.
- Windows users work with WebView2, which is included in current Edge releases.
This strategy keeps the build clean and the runtime lean, which is useful for small tools, internal dashboards, or local editors where a full GUI toolkit feels like overkill.
A minimal “Hello world” in four lines
Getting started takes only a few lines of Go. After importing the package, you create a window, set its size and title, inject HTML, and run the event loop.
package main
import (
"log"
"github.com/crgimenes/glaze"
)
func main() {
w, err := glaze.New(true)
if err != nil {
log.Fatal(err)
}
defer w.Destroy()
w.SetTitle("Glaze")
w.SetSize(800, 600, glaze.HintNone)
w.SetHtml("<h1>Hello from Glaze</h1>")
w.Run()
}The result is a native window hosting a WebView, rendered with the operating system’s engine, all from standard Go without any external toolchain.
Turning HTTP handlers into desktop apps
One common pattern is wrapping an existing net/http server inside a desktop window. Glaze’s AppWindow helper lets you reuse handlers with a few extra lines.
package main
import (
"fmt"
"log"
"net/http"
"github.com/crgimenes/glaze"
)
func main() {
mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
_, err := fmt.Fprint(w, `<!doctype html>
<html lang="en">
<head><meta charset="utf-8"><title>Glaze App</title>
<style>
body { font-family: system-ui, sans-serif; margin: 2rem; }
button { font: inherit; padding: 0.5rem 1rem; }
</style>
</head>
<body>
<h1>Local Go UI</h1>
<p>This page is served by a Go http.Handler and displayed in a desktop WebView.</p>
<button onclick="location.reload()">Reload</button>
</body>
</html>`)
if err != nil {
log.Printf("write response: %v", err)
}
})
err := glaze.AppWindow(glaze.AppOptions{
Title: "Glaze App",
Width: 1024,
Height: 700,
Handler: mux,
})
if err != nil {
log.Fatal(err)
}
}This approach is ideal for internal tools, local dashboards, or prototypes where the UI can stay in HTML, CSS, and JavaScript while the logic remains in Go.
Exposing Go functions to JavaScript
Glaze also enables bidirectional communication between Go and JavaScript. Exported Go methods can be bound to the window object, letting JavaScript trigger Go functions without a server round-trip.
package main
import (
"log"
"github.com/crgimenes/glaze"
)
func sayHello(name string) string {
return "Hello, " + name + " from Go!"
}
func main() {
w, err := glaze.New(true)
if err != nil {
log.Fatal(err)
}
defer w.Destroy()
w.BindMethod("sayHello", sayHello)
w.SetHtml(`
<button onclick="alert(window.sayHello('World'))">
Click to call Go
</button>
`)
w.Run()
}This pattern works well for small surface areas—saving files, running calculations, or triggering events—while keeping most logic in Go and the UI lightweight.
What Glaze isn’t trying to solve
Glaze deliberately avoids becoming a full desktop framework. It does not package installers, handle auto-updates, manage application icons, or provide custom widgets. Those concerns are better left to mature toolkits like Qt, Electron, or GTK.
Instead, Glaze targets scenarios like:
- Turning a CLI tool into a small desktop utility.
- Running an internal HTTP dashboard in a native window.
- Building a local editor or inspector with HTML/CSS.
- Keeping the build process simple and CGo-free.
By focusing on a narrow slice, the API stays small and predictable, making it easier to integrate into existing Go workflows.
Platform notes and feedback needed
macOS provides the cleanest experience because Apple’s WebKit and Cocoa frameworks ship with the OS. Windows users usually already have WebView2 installed through Edge, though offline deployments may need to bundle the runtime.
Linux remains the trickiest target. Different distributions package WebKitGTK under various names and versions, and library discovery can break builds. Glaze currently prefers GTK4 and WebKitGTK, falling back to GTK3 where needed, but more testing across distributions is welcome.
If you rely on Linux desktops, testing Glaze on your distribution and sharing feedback would help improve platform support.
What’s inside the current release
- Native WebView windows across macOS, Windows, and Linux.
- JavaScript-to-Go bindings for calling Go functions from the browser.
- A
BindMethodshelper to expose Go methods to JavaScript. RenderHTMLfor templating with Go’shtml/template.AppWindowto wrapnet/httphandlers.- Event bridges from Go to JavaScript.
- Native file dialogs and basic menu support on macOS and Windows.
For developers who want a thin WebView layer without CGo overhead, Glaze offers a focused solution that fits neatly into Go’s ecosystem.
AI summary
Go dilinde masaüstü uygulamaları geliştirirken WebView kullanmak istiyorsanız, CGo gereksinimi olmadan nasıl yapabileceğinizi Glaze aracıyla öğrenin. Temiz ve taşınabilir Go masaüstü uygulamaları oluşturun.