Migrate to gonx 3.0.0
import { Steps } from ‘@astrojs/starlight/components’;
gonx 3.0.0 requires Nx 23 and infers Go targets from go.mod files instead of
generating project.json targets. Adapt your workspace with the steps below.
Before you start
Section titled “Before you start”- Nx 23.x or later
- Go — a stable release (1.18+ for multi-module workspaces)
- A backup of your workspace
-
Remove nx-go and install gonx If migrating from @nx-go/nx-go, uninstall it first:
npm uninstall @nx-go/nx-goThen install gonx and apply its migrations:
npx nx add @naxodev/gonxIf you are upgrading from an earlier gonx release,
nx addpicks up the migration prompts automatically. -
Register the gonx plugin in
nx.json{ "plugins": ["@naxodev/gonx"] }Remove any nx-go plugin entry. gonx infers targets from
go.mod, so no per-project config is needed. -
Delete hand-written Go targets gonx infers
build,serve,test,lint,tidy, andgeneratefrom eachgo.mod. The main package is auto-detected — a project withpackage mainandfunc main()inmain.go, or acmd/directory, is treated as an application and getsbuildandservetargets. Removeproject.jsonfiles that hand-write those targets:rm apps/my-go-app/project.jsonKeep
project.jsononly for non-Go projects or custom overrides. gonx uses the full project root path as the project name (for example,apps/my-go-app), not just the final directory segment — this aligns with Go’s release tagging convention (projectRoot/vx.x.x). Update any scripts or CI that reference short project names. -
Remove the
cwdserve option and reviewcmd/compilervalues Thecwdserve option no longer exists — serve runs from the project root. Deleteoptions.cwdfrom any hand-written serve target. Because the main package is auto-detected,options.mainis optional. The servecmdand buildcompileroptions now acceptgowalongsidegoandtinygo. See the serve executor guide and build executor guide. -
Decide whether to keep
go.workgonx no longer creates ago.workfile by default. Build and serve work without one. Keep an existinggo.workonly if you intentionally use a multi-module workspace. To opt in when initializing gonx:npx nx g @naxodev/gonx:init --addGoDotWork -
Remove
convert-to-one-modusage Theconvert-to-one-modgenerator was removed. Delete any script or doc that invokesnx g @naxodev/gonx:convert-to-one-mod. Consolidate modules manually with standard Go tooling.
Verify
Section titled “Verify”Confirm Nx detects your Go projects and infers their targets:
npx nx show projects
npx nx show project apps/my-go-app
nx show project lists the inferred targets with no leftover cwd options.
Then build a project to confirm it works without go.work:
npx nx build apps/my-go-app
Next steps
Section titled “Next steps”- Plugin options — customize target names and tags
- Create your first Go project — walkthrough of generators and executors
- nx-release-publish executor — publish Go modules