Development setup
Build NSGo from source, run the gallery and test a change.
Requirements
Section titled “Requirements”macOS with Xcode and Go 1.27.3 or later builds every target for arm64, Android’s APK included. Running on devices needs what Setup lists, and the x86_64 Android emulator’s target, android_x64, an Android NDK, since Go links android/amd64 only with cgo. Windows setup and uninstall programs build with Go alone.
git clone https://github.com/nsgo-dev/nsgo.gitcd nsgoRead ARCHITECTURE.md and AGENTS.md before changing code.
The gallery
Section titled “The gallery”The gallery has a demo of each element, base and ui component and service. A wide window shows the demos under tabs in a sidebar; a narrow one shows the tabs and the settings in a bottom bar, with demos pushed over them. Run it from the repository’s root:
go tool nsgo dev examples/gallery # nsgo.yaml's dev target, exiting with the appgo tool nsgo dev examples/gallery-tsx # the gallery's components and apps, written in TSXgo tool nsgo dev -target web examples/gallery # in the browser, serving until interruptedgo tool nsgo dev -target ios_simulator examples/gallerygo tool nsgo dev -target ios examples/gallery # on the connected iPhone, signed by Xcodego tool nsgo dev -target android examples/gallery # on the connected device or emulator, over adbgo tool nsgo build -target all examples/gallery # every platform's packages in examples/gallery/dist, what to hand out in dist/releasesCheck and test
Section titled “Check and test”go tool nsgo check # vet every packagego tool nsgo check -target all # vet every available Go/Xcode target insteadgo tool nsgo test # every package's testsgo tool nsgo test -bench . ./core # core's benchmarks(cd benchmark && go run ./runner) # measure against other frameworks# capacity curve for NSGo's 600-cell grid, without rebuilding it(cd benchmark && go run ./runner -frameworks nsgo -cases grid -grid-cols 20 -grid-rows 15 -out /tmp/grid.json)-target vets the targets it names instead of the host and, in NSGo’s repository, the dev client, which the plain check vets. To vet the platforms a change touches, name them all in one check, such as check -target web,android -jobs 2, rather than starting several: -jobs n vets up to n targets at once, each go vet with n compile workers, where the default is one target at a time with Go’s default, and a check started while another runs in the same module waits for it and says so. CI’s check.yml vets every target.
Reports use expanded target names: linux, for example, becomes linux_arm64 and linux_x64. If a target’s build constraints leave no packages matching ./..., check lists that target as skipped with the reason and vets the other targets. If every target is skipped, the command fails because nothing was vetted.
Run at the repository root, or in internal/dev, the headless command tests internal/dev a second time with the nsgodev build tag, which the dev client’s files need, so its tests run locally and in CI. Both runs take the same filters and flags and share one tally and JUnit report, where the second run’s package is named internal/dev [nsgodev].
check -target all vets the macOS, Windows, Linux, Android arm64 and web targets on any host. It also vets iOS, tvOS and watchOS when their Xcode SDKs are available, and lists the ones it skips. An explicitly named target, such as check -target ios, fails if its tools are unavailable, including when combined with all. A failed target does not prevent checking the remaining targets, and the command fails if any required check fails. build -target all still needs macOS with Xcode. In NSGo’s own repository, each named target also vets its platform test hosts with nsgotest; CI names the preview harmonyos target explicitly, since it is outside all.
The Linux CI job runs the HarmonyOS Go backend’s js/wasm tests with Node.js and Go’s Wasm launcher. Run the gallery test locally with a HarmonyOS emulator connected through hdc. Compiling the HarmonyOS host templates requires OpenHarmony SDK API 26.
go tool nsgo test -env GOOS=js -env GOARCH=wasm ./internal/platform/harmonyos \ -- "-exec=env -i \"PATH=$PATH\" \"$(go env GOROOT)/lib/wasm/go_js_wasm_exec\"" -count=1go tool nsgo test -target harmonyos -run TestHarmonyOSPages -timeout 10m ./examples/galleryIn a Wayland session on a Linux desktop, run the real global-shortcut portal acceptance check with NSGO_TEST_GLOBAL_SHORTCUT_PORTAL=<installed-desktop-id> go tool nsgo test -run TestGlobalShortcutPortalWithPermission ./internal/platform/linux. The ID must have a .desktop entry. Grant Ctrl+Alt+K in the compositor’s prompt, then press it with another application focused; the check waits for both registration and activation. It is skipped unless the environment variable is set.
With Docker available on a Linux host, go tool nsgo test -run '^TestLinuxPackagesNative$' -env NSGO_TEST_LINUX_PACKAGES=1 ./cmd/nsgo -- -timeout=20m checks real installs in disposable Debian, Ubuntu and Arch containers. It downloads their official images and installs GTK dependencies inside them, verifies each package database and the installed files, then removes the package. The host’s package database is never used.
Releases
Section titled “Releases”NSGo releases on demand when a downstream project needs a tagged version or maintainers have changes ready to ship. When requesting a release for a library, link the dependent work and name the commit that contains the last NSGo change it needs. The first release tag that contains that commit is the version the library can require.
To test a merged change before it is tagged, run go get github.com/nsgo-dev/nsgo@main from the dependent module. You can use a commit ID in place of main to select the revision you verified. Go records the resulting pseudo-version in go.mod.
A maintainer runs go run ./tools/changelog release X.Y.Z on a chore/release-X.Y.Z branch from an up-to-date main, which gives the changes their version and date in CHANGELOG.md and leaves a fresh Unreleased section. When a commit has changed the Android runtime’s Java or build inputs since classes.dex and classes.jar were last rebuilt, it also starts the Android runtime workflow on main with gh, waits for it and writes the files it built into internal/platform/android/runtime/, so the same pull request commits them; this needs gh signed in with the right to run workflows, and -no-runtime skips it when the runtime was rebuilt by hand with build.sh in a bot/android-runtime pull request. The maintainer merges the pull request to main, then runs the release workflow with that version: gh workflow run release.yml -f version=X.Y.Z. The workflow runs every check and test on main’s tip and only once they pass tags that commit vX.Y.Z and publishes it, so a failure leaves the version free; the published notes then leave CHANGELOG.md, which keeps only unreleased changes, for Releases.
Each release attaches a prebuilt nsgo for macOS, Linux and Windows on arm64 and amd64, built from the tagged commit with CGO_ENABLED=0 go build -trimpath ./cmd/nsgo, whose nsgo version prints vX.Y.Z. The archives are nsgo_X.Y.Z_<os>_<arch>.tar.gz, .zip for Windows, with <os> one of darwin, linux and windows and <arch> one of arm64 and amd64; each holds nsgo (nsgo.exe on Windows), LICENSE and README.md at its root. checksums.txt lists every archive’s SHA-256 in sha256sum’s format, so sha256sum -c checksums.txt checks a download. They live at https://github.com/nsgo-dev/nsgo/releases/download/vX.Y.Z/<asset>. The install script and the Homebrew tap read these names, so they do not change. go run ./tools/release -out <dir> X.Y.Z builds and checks them from a clean checkout of the commit tagged vX.Y.Z, the same as the release workflow, and a pull request that changes the build runs it without publishing anything.
NSGo reads Native Shell as a design reference; none of its tests need it. To read it, clone it beside the repository and check out its latest release tag, never main:
git clone https://github.com/longbridge/nsh.git ../nshgit -C ../nsh checkout "$(git -C ../nsh describe --tags --abbrev=0)"- The codebase: where each part of NSGo lives.
- Making a change: what a pull request needs.