MyGo 0.3.0 makes native UI controls safe to rebuild: an element retained from an earlier build can no longer silently refer to a different control when its storage is reused. This is a breaking release for apps using ui. Apps using only webviews can upgrade without the native UI migration.
Patch update: For new upgrades, use MyGo 0.3.3. The original 0.3.0 input timing was revised in the patches: 0.3.2 restored same-build Changed() and Submitted() polling, and 0.3.3 makes public click and shortcut queries apply pending bound edits before returning and fixes same-build combobox choice handling. Inline polling remains supported; callbacks are optional. The commands below target the original 0.3.0 release.
Upgrade
Update the Go module in your app:
go get github.com/egoist/mygo@v0.3.0If your project pins the CLI as a Go tool, update it too:
go get -tool github.com/egoist/mygo/cmd/mygo@v0.3.0For projects with a web frontend:
bun add mygo-runtime@0.3.0
bun add -d mygo-cli@0.3.0Update any installed @mygo-plugins/fetch, @mygo-plugins/websocket, or @mygo-plugins/sqlite packages to 0.3.0 as well; they now require mygo-runtime ^0.3.0. Regenerate your TypeScript client with your project's mygo generate command.
Native UI: what to change
- Use values for build results. Constructors return
ui.Element, and custom control parts are values too. Replace*ui.Elementdeclarations, useui.Element{}for an absent element, and use.Valid()instead of a nil check. Elements expire before the next build pass, including a rebuild in the same frame. Development builds andui.Testerreport stale use; production builds ignore stale operations or return empty results. - Keep persistent identity in
ui.Handle. Bind a control with.Bind(&handle)and use the handle for focus requests, focus queries, committed bounds, and control shortcuts across builds. Focus requests wait while a control is hidden. When sharing a handle across windows, pass that window's context tohandle.Focus(c). - Key stateful controls before construction. Replace patterns such as
ui.TextInput(c, &query).Key("search")withui.TextInput(c.Key("search"), &query)so the key is available when widget state is initialized. - Review input bindings and actions. Configure
Disabled,ReadOnly, and range settings before querying responses. The original 0.3.0 deferred bound input until after construction and reportedChangedandSubmittedin the following build. In 0.3.2 and later, those queries apply pending input before returning, so derived local values can be committed inline in the same build. In 0.3.3, public click and shortcut queries also see pending bound edits..OnClick,.OnChange,.OnSubmit, and.OnShortcutremain useful when an action should run after construction, such as when it changes the collection being built. - Use
Servicesfor persistent callbacks. Capturec.Services()for clipboard, URL, or background redraw access, and publish worker results throughWindow.Update.
The CLI helps with the mechanical changes. From your app directory, after updating the CLI:
go tool mygo migrate-ui . # preview affected files
go tool mygo migrate-ui -write . # apply the source migration
go tool mygo vet .
go test ./...Review the resulting diff. The migration updates element/parts pointer types, nil checks, constructor keys, and grid Rows(n) calls to GridRows(n). Persistent handles, services, derived-value bindings, and arbitrary polling actions still need manual review. mygo vet combines ordinary Go vet with checks for UI build values stored in app state or used by goroutines.
New FocusBind and FocusedValue APIs connect desired focus to app data while letting you query actual focus separately. Fluent lists accept .Rows(func(row ui.ListRow) { ... }), exposing the row context, index, selection, and list focus; the existing four-argument list callback remains supported.
See the updated migration guide for examples and the performance report for measurements.
CLI: app dependencies can opt into cgo
mygo dev, mygo build, and mygo generate now respect an explicit CGO_ENABLED value. The default remains 0; MyGo itself still builds without cgo. If an app dependency needs it:
CGO_ENABLED=1 go tool mygo dev
CGO_ENABLED=1 go tool mygo buildThese builds require a C compiler for the target platform. When cross-compiling, set CC to a suitable cross compiler. See the distribution guide.
Full changelog: 0.2.18 → 0.3.0