今日已更新 166 条资讯 | 累计 20138 条内容
关于我们

Building desktop WebView apps in Go without CGo

Cesar Gimenes 2026年06月30日 11:54 3 次阅读 来源:Dev.to

I have been working on Glaze , a small desktop WebView toolkit for Go. The short version: Glaze lets a Go program open a native desktop window backed by the WebView already available on the operating system, without using CGo. It currently targets: macOS, through WKWebView Linux, through WebKitGTK Windows, through WebView2 The project is still young, but the core idea is already useful: keep small Go desktop tools close to the normal Go workflow. No C compiler in the build path. No bundled native helper library. No large application framework around it. Just Go code calling the system WebView. Why I wanted this I write a lot of small tools in Go. Some of them are fine as CLI programs. Others need a basic interface: a form, a preview, a local dashboard, a small editor, or a way to inspect and manipulate data visually. For those cases, HTML is often enough. The browser gives me layout, text rendering, forms, tables, keyboard handling, and a familiar debugging model. But I do not always want to ship a web server as the user interface. I also do not always want to pull in a large desktop framework when all I need is a native window around a local UI. A WebView is a reasonable middle ground. The problem is that many WebView solutions eventually bring CGo, native build tooling, helper libraries, or larger framework assumptions into the project. That is not necessarily wrong. For many applications, those trade-offs are acceptable. For this project, I wanted something narrower. The design constraint The main constraint behind Glaze is simple: Use the WebView already provided by the OS, but call it from Go without CGo. Glaze uses purego to call native platform APIs directly from Go. That means each backend talks to the platform WebView: WKWebView on macOS WebKitGTK on Linux WebView2 on Windows The result is not a full GUI toolkit. That is intentional. Glaze is focused on the window, the WebView, JavaScript-to-Go bindings, and a few desktop helpers that are useful for small t

本文内容来源于互联网,版权归原作者所有
查看原文