You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, and thanks for BUI. I've built an experimental Go binding over BUI_kit.h: CWBudde/bui-go. It's a Linux amd64 spike with a small API: nodes, properties, pack layout, windows, click and change events, and Do for calling the UI thread from goroutines. It links static libraries built at a pinned BUI commit, because go get can't run CMake.
I have three questions:
Is anyone already working on Go support? If so, I'd rather coordinate than duplicate it.
Would you want Go bindings in this repo, or are they better kept separate? I'm happy to keep maintaining it separately. bindings/rust suggests in-tree could also work, but Go's module system would need either committed binaries or a required CMake step.
Two other things came up while I was building it:
BUI_kit.h has no stability promise, so I'm pinning a commit. Is there a plan to version it?
The README and SPDX headers say GPL-2.0-or-later, but LICENSE contains the GPLv3 text. Which do you intend? I've mirrored both for now, and I'd like to get this right because the binding ships binaries.
Thanks! Before I open a PR: the binding has changed a lot since I opened this issue, so you may want a say in how it lands.
It no longer needs cgo. The kit is compiled to one WebAssembly module, embedded in the Go package and run by wazero, so CGO_ENABLED=0 go build works. That gives headless rendering on any OS and, on Linux, a real window through an X11 host written in Go. Rendering is software only: no GPU, video, file browser or IME, no windows on Windows or macOS yet, and a wasm trap ends the process. The reasons and measurements are in docs/design.md.
It's about 21k added lines, so I'd split it into focused PRs: first the wasm engine and headless API, then the X11 host. Nothing would change in CMake, features.json or your existing builds.
Four things I'd like your view on first:
Committed wasm.go get only fetches bindings/go and can't run CMake, so the module (about 3.5 MB) has to be committed, and each update adds to the repo's history. I'd drop the prebuilt .a files and make the cgo engine opt-in, using libraries built with CMake. Is one committed .wasm OK?
A second X11 host. The wasm module can't reach the X server, so the Go host reimplements kit_window_x11.c. AGENTS.md discourages duplication, but I don't see a cgo-free way around this one. Are you OK with it? If not, I'd start with headless only.
Pinning. The wasm would be built from a pinned commit and updated deliberately, with Go CI running only on bindings/go/**, so kit commits can't fail on Go. Or would you rather have Go CI on every commit, which means rebuilding the wasm with each kit change?
Releases. The module would be github.com/ppmpreetham/BUI/bindings/go, and Go needs tags named bindings/go/vX.Y.Z. Are you OK with those tags in the repo?
Thanks, this is a big piece of work, and a Go binding with no cgo is a good fit for BUI.
Yes to splitting into PRs: wasm engine + headless API first, windowing later.
Committed wasm. I'd rather not add a 3.5 MB binary to main's history on every update. Could the module be built by CI from the release tag, and committed only by a bot on a separate branch or repo (for example ppmpreetham/BUI-go, which go get can fetch) so main stays clean? CI should also rebuild the wasm from the pinned commit, with a pinned toolchain, and fail if its checksum differs from the committed one, so people can verify it. How much does the size grow per release?
Second X11 host. I'm not keen on rewriting kit_window_x11.c in Go: that file changes often
(Wayland, GPU start, IME and framosts), and a copy in Go will drift.
Could the headless package expose "render to a pixel buffer + feed events" (the kit's BK_press,
BK_key, BK_motion calls) so apps ary for the window? Then your X11
host can be a separate optional package, outside the core binding. If you still want it in the
repo, I'd want it clearly marked , with the same behaviour.
Pinning. Go CI only on bindingmit is fine. I'd add one gate: therelease workflow rebuilds the wasm from the release tag and runs the Go tests, and tools/check_versions.py checks thhe kit version, so a release can't
ship a stale wasm.
Tags. bindings/go/vX.Y.Z is fine if the number matches the BUI version. Please add it to the
release flow (tools/release.py angged by hand.
Could you also add:
startup time, frame time and memory against the native kit, like the other bindings on the
website benchmarks page
wazero's license in THIRD_PARTY_NOTICES (tools/gen_notices.py --check runs in release CI)
a CHANGELOG entry, docs, READMETS.md)
the API generated from BUI_kit.h instead of by hand, so it can't drift from the kit
a way to catch a wasm trap instead of ending the process
Thanks for the detailed answer. Here is how I'd handle each point. Unless you object, I'll rework PR 1 along these lines.
1. Committed wasm. I'd keep all source in bindings/go on main and move only the binary out: a small Go module in a separate repository, for example ppmpreetham/BUI-go, that holds bui_kit.wasm and the few lines that embed it. bindings/go requires that module at the BUI version, so users still import github.com/ppmpreetham/BUI/bindings/go. The release workflow builds the wasm from the release tag with the pinned wasi-sdk, and a bot commits and tags it there. CI rebuilds it from the pinned commit and fails if its checksum differs from the published one. For work on main itself, a script builds the module locally and a go.work file points the binding at it.
On size: from v0.4.1 to v0.5.0 the module grew by 2,445 bytes (3,454,663 to 3,457,108). It is 1.33 MB gzipped, which is an upper bound for what each release adds to that repository's history.
Could you create the repository, or tell me which name you'd prefer? The bot will need a token that can push to it.
2. Second X11 host. Agreed. Headless now has the API you describe: it renders into an *image.RGBA and reports the rectangles that changed, and it takes press, release, motion, wheel and key events with modifiers. Through a Host interface, the program's own window gets the kit's redraw requests, cursor changes, pointer warps, clipboard and timers. A program with its own event loop runs queued work with Flush. So the core binding will be headless only. The X11 and Cocoa hosts become an optional module outside BUI, built on that API, and BUI won't carry a copy of kit_window_x11.c.
3. Pinning. Go CI runs only on bindings/go/**. I'll add your gate to the release workflow: it rebuilds the wasm from the release tag and runs the Go tests, and tools/check_versions.py checks the kit version that bindings/go pins.
4. Tags.bindings/go/vX.Y.Z with the BUI version number, made by tools/release.py.
The other points:
wazero's licence is in THIRD_PARTY_NOTICES.md, rendered by tools/gen_notices.py, and --check passes. The CHANGELOG entry, docs, the README's bindings table and the website are ready in the PRs too.
Benchmarks: I have frame times against the native kit. On amd64 and arm64 the wasm engine renders at about 2–4x native time. I'll add startup time and memory in the format of the benchmarks page.
Generating the API from BUI_kit.h: agreed, as a follow-up after PR 1, so that the binding can't drift from the kit.
Catching a wasm trap: agreed, also after PR 1. A module that trapped is in an unknown state, so the binding will report the error, from Run and through a hook, and refuse further kit calls instead of ending the process.
PR 1 will be the wasm engine with the headless and embedding API, rebased onto current main. I'll open it once the wasm repository is settled.
Go bindings are now in the main repo through #53, in bindings/go. There are two packages: bui (the C kit over cgo) and ui (MyGo-style views).
CI tests them on Ubuntu and Windows. Thanks for your bui-go spike, it showed the way. Closing this, but feel free to open issues for anything your binding did that this one doesn't.
Activity
[-]Go bindings: experimental cgo binding, and what is MyGo?[/-][+]Go bindings: experimental cgo binding[/+]ppmpreetham commentedon Nov 6, 2026
Thanks for opening the issue!
They're some pretty neat bindings!
Feel free to open a PR!
BUI_kit.hwill soon be versionedCWBudde commentedon Nov 7, 2026
Thanks! Before I open a PR: the binding has changed a lot since I opened this issue, so you may want a say in how it lands.
It no longer needs cgo. The kit is compiled to one WebAssembly module, embedded in the Go package and run by wazero, so
CGO_ENABLED=0 go buildworks. That gives headless rendering on any OS and, on Linux, a real window through an X11 host written in Go. Rendering is software only: no GPU, video, file browser or IME, no windows on Windows or macOS yet, and a wasm trap ends the process. The reasons and measurements are in docs/design.md.It's about 21k added lines, so I'd split it into focused PRs: first the wasm engine and headless API, then the X11 host. Nothing would change in CMake,
features.jsonor your existing builds.Four things I'd like your view on first:
go getonly fetchesbindings/goand can't run CMake, so the module (about 3.5 MB) has to be committed, and each update adds to the repo's history. I'd drop the prebuilt.afiles and make the cgo engine opt-in, using libraries built with CMake. Is one committed.wasmOK?kit_window_x11.c.AGENTS.mddiscourages duplication, but I don't see a cgo-free way around this one. Are you OK with it? If not, I'd start with headless only.bindings/go/**, so kit commits can't fail on Go. Or would you rather have Go CI on every commit, which means rebuilding the wasm with each kit change?github.com/ppmpreetham/BUI/bindings/go, and Go needs tags namedbindings/go/vX.Y.Z. Are you OK with those tags in the repo?ppmpreetham commentedon Nov 9, 2026
Thanks, this is a big piece of work, and a Go binding with no cgo is a good fit for BUI.
Yes to splitting into PRs: wasm engine + headless API first, windowing later.
Committed wasm. I'd rather not add a 3.5 MB binary to main's history on every update. Could the module be built by CI from the release tag, and committed only by a bot on a separate branch or repo (for example ppmpreetham/BUI-go, which
go getcan fetch) so main stays clean? CI should also rebuild the wasm from the pinned commit, with a pinned toolchain, and fail if its checksum differs from the committed one, so people can verify it. How much does the size grow per release?Second X11 host. I'm not keen on rewriting kit_window_x11.c in Go: that file changes often
(Wayland, GPU start, IME and framosts), and a copy in Go will drift.
Could the headless package expose "render to a pixel buffer + feed events" (the kit's BK_press,
BK_key, BK_motion calls) so apps ary for the window? Then your X11
host can be a separate optional package, outside the core binding. If you still want it in the
repo, I'd want it clearly marked , with the same behaviour.
Pinning. Go CI only on bindingmit is fine. I'd add one gate: therelease workflow rebuilds the wasm from the release tag and runs the Go tests, and tools/check_versions.py checks thhe kit version, so a release can't
ship a stale wasm.
Tags. bindings/go/vX.Y.Z is fine if the number matches the BUI version. Please add it to the
release flow (tools/release.py angged by hand.
Could you also add:
website benchmarks page
CWBudde commentedon Nov 12, 2026
Thanks for the detailed answer. Here is how I'd handle each point. Unless you object, I'll rework PR 1 along these lines.
1. Committed wasm. I'd keep all source in
bindings/goonmainand move only the binary out: a small Go module in a separate repository, for exampleppmpreetham/BUI-go, that holdsbui_kit.wasmand the few lines that embed it.bindings/gorequires that module at the BUI version, so users still importgithub.com/ppmpreetham/BUI/bindings/go. The release workflow builds the wasm from the release tag with the pinned wasi-sdk, and a bot commits and tags it there. CI rebuilds it from the pinned commit and fails if its checksum differs from the published one. For work onmainitself, a script builds the module locally and ago.workfile points the binding at it.On size: from v0.4.1 to v0.5.0 the module grew by 2,445 bytes (3,454,663 to 3,457,108). It is 1.33 MB gzipped, which is an upper bound for what each release adds to that repository's history.
Could you create the repository, or tell me which name you'd prefer? The bot will need a token that can push to it.
2. Second X11 host. Agreed.
Headlessnow has the API you describe: it renders into an*image.RGBAand reports the rectangles that changed, and it takes press, release, motion, wheel and key events with modifiers. Through aHostinterface, the program's own window gets the kit's redraw requests, cursor changes, pointer warps, clipboard and timers. A program with its own event loop runs queued work withFlush. So the core binding will be headless only. The X11 and Cocoa hosts become an optional module outside BUI, built on that API, and BUI won't carry a copy ofkit_window_x11.c.3. Pinning. Go CI runs only on
bindings/go/**. I'll add your gate to the release workflow: it rebuilds the wasm from the release tag and runs the Go tests, andtools/check_versions.pychecks the kit version thatbindings/gopins.4. Tags.
bindings/go/vX.Y.Zwith the BUI version number, made bytools/release.py.The other points:
THIRD_PARTY_NOTICES.md, rendered bytools/gen_notices.py, and--checkpasses. The CHANGELOG entry, docs, the README's bindings table and the website are ready in the PRs too.BUI_kit.h: agreed, as a follow-up after PR 1, so that the binding can't drift from the kit.Runand through a hook, and refuse further kit calls instead of ending the process.PR 1 will be the wasm engine with the headless and embedding API, rebased onto current
main. I'll open it once the wasm repository is settled.ppmpreetham commentedon Nov 27, 2026
Go bindings are now in the main repo through #53, in bindings/go. There are two packages: bui (the C kit over cgo) and ui (MyGo-style views).
CI tests them on Ubuntu and Windows. Thanks for your bui-go spike, it showed the way. Closing this, but feel free to open issues for anything your binding did that this one doesn't.