A Go GUI, in a few steps.
Build a small counter application with GOUI v0.4.0. The same interface code targets Windows, macOS and Linux; no C/C++ compiler is needed.
Create a module
Pin the release so this tutorial does not silently move to a newer API.
mkdir hello-goui
cd hello-goui
go mod init example.com/hello-goui
go get github.com/golang-gui/goui@v0.4.0Develop with an AI assistant
Install the official goui-app skill so your coding assistant knows GOUI application development. Send the following instruction to your tool; whether it loads skills is decided by the tool itself. Install instructions
Install the GOUI application development skill following https://github.com/golang-gui/goui/blob/main/skills/INSTALL.md.Write your interface
Save the following as main.go. The Modern stylesheet follows system settings; clicking the button updates the state and rebuilds the view.
package main
import (
"fmt"
"log"
"github.com/golang-gui/goui/theme/modern"
"github.com/golang-gui/goui/ui"
)
func main() {
count := ui.MakeState(0)
err := ui.Run("com.example.Hello", func(app ui.App) ui.RootView {
return ui.Root().
StyleSheet(modern.FromSettings(app.Settings())).
Windows(
ui.Window("main").
Title("Hello GOUI").
Size(480, 240).
Content(
ui.VBox(
ui.Label(fmt.Sprintf("Clicked %d times", count.Get())),
ui.Button("Click me").OnClick(func() {
count.Update(func(old int) int { return old + 1 })
}),
).Spacing(12).Padding(20),
),
)
})
if err != nil {
log.Fatal(err)
}
}
Build and run
On Linux or macOS, use the following commands. Run the application on your desktop, not in a session without a display.
CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o hello-goui .
./hello-gouiWindows PowerShell
Use -H=windowsgui to build without a console window. Omit that flag while debugging if you want to see terminal output.
$env:CGO_ENABLED='0'
go build -trimpath -ldflags="-s -w -H=windowsgui" -o hello-goui.exe .
.\hello-goui.exeChoose the next layer
ui is the declarative adapter; gui provides imperative widgets; widgets contains additional controls. Application behavior belongs to your app, not the view declarations.
Building is not always packaging.
An ordinary go build is enough to create the executable. The optional cmd/goui tool prepares Windows icon/version resources, macOS .app metadata and icons, and Linux desktop/icon resources from goui.toml. It does not remove system runtime requirements.
Read the build and package guideRuntime requirements
Windows
Windows x64 · Win32 windows · DirectWrite text · Direct2D, OpenGL or Software drawing.
macOS
macOS Apple Silicon · AppKit windows · Core Text · OpenGL or Software drawing. Signing and notarization remain application distribution steps.
Linux
Linux x64 · X11 · Pango/Cairo text · OpenGL or Software drawing. Needs native X11, GL, GLib, Fontconfig, Pango/Cairo and GTK runtime libraries. Wayland sessions require XWayland; behavior must be checked on the target desktop.