Skip to content

Migration from nx-go

This guide helps you migrate from the original @nx-go/nx-go plugin to GoNx.

GoNx is a modernized fork of nx-go with significant architectural changes:

  1. Modern Nx-only: Requires Nx 21.x or later
  2. No project.json generation: Uses inferred tasks instead
  3. Changed command execution: Runs from project root instead of workspace root
  4. Removed go.work creation: Now opt-in via configuration
  5. Removed legacy generators: convert-to-one-module is no longer available
  1. Inferred tasks: Automatic task detection and configuration
  2. Cacheable operations: All tasks are properly cached
  3. CreateNodesV2: Latest Nx project detection API
  4. Version Actions: Proper Go versioning with Nx Release
  5. Publish executor: Automated registry publishing

Before starting the migration:

  1. Upgrade Nx: Ensure you’re on Nx 21.x or later
  2. Update Go: Use a stable Go version (1.21+ recommended)
  3. Backup your workspace: Create a backup before making changes
  4. Review project structure: Understand your current setup

Remove the original nx-go plugin:

Terminal window
npm uninstall @nx-go/nx-go
# or
pnpm remove @nx-go/nx-go
# or
yarn remove @nx-go/nx-go

Install the GoNx plugin:

Terminal window
npm install @naxodev/gonx
# or
pnpm add @naxodev/gonx
# or
yarn add @naxodev/gonx

Update your nx.json to use GoNx:

{
"plugins": [
{
"plugin": "@naxodev/gonx",
"options": {
"addGoDotWork": false
}
}
]
}

Remove any nx-go specific configuration.

GoNx uses inferred tasks, so you can remove project.json files from your Go projects:

Terminal window
# Remove project.json files from Go projects
rm apps/my-go-app/project.json
rm libs/my-go-lib/project.json

Update any scripts or CI configurations that reference nx-go:

{
"scripts": {
"build:go": "nx run-many --target=build --projects=tag:go",
"test:go": "nx run-many --target=test --projects=tag:go"
}
}

Update your CI to use the new executors and ensure Go is available in the environment.


Problem: GoNx changed how project names are inferred

Solution: While nx-go uses the given name for the projects or the final segment of the path as the name, GoNx uses the entire path as the project name.

Although this can make commands longer, it has two main benefits:

  • Removes the disambiguation name problem.
  • Aligns perfectly with the Go standard for multi-module repository tag creation.

Reference

Problem: Nx doesn’t recognize Go project tasks.

Solution:

  1. Ensure go.mod files exist in your Go projects
  2. Clear Nx cache: nx reset
  3. Verify plugin configuration in nx.json

Problem: Project dependencies aren’t detected correctly.

Solution:

  1. Ensure Go imports are correctly structured
  2. Use proper module paths
  3. Clear cache and regenerate: nx reset && nx graph

After migration, verify everything works:

Terminal window
nx show projects
Terminal window
nx build my-go-app
nx test my-go-lib
nx lint my-go-app
Terminal window
nx graph
Terminal window
nx build my-go-app
nx build my-go-app # Should use cache

If you encounter issues during migration:

  1. Check documentation: Review GoNx documentation thoroughly
  2. Search issues: Look for similar issues on GitHub
  3. Join Discord: Get real-time help on our Discord server
  4. Create issue: Report bugs or request help on GitHub