Skip to content

Quick Start

gonx - Nx plugin for Go/Golang

GoNx

A modern Nx plugin for Go/Golang development

GoNx - A very opinionated Nx plugin for Go/Golang

The philosophy of gonx is to generate a non-invasive tooling to work with Go and Nx, heavily relying on inferred tasks and modern Nx features.

Before getting started, ensure you have:

  • Node.js (version 18 or later)
  • npm, pnpm, or yarn package manager
  • Nx CLI (npm install -g nx or npm install -g @nx/cli)

For GoNx specifically:

gonx is compatible with the following Nx versions:

Nx Versiongonx Version
21.x>=^1.0.0 <=^2.0.0

Option 1: Create a New Workspace with GoNx

Section titled “Option 1: Create a New Workspace with GoNx”

If you want to start a new workspace focused on Go development:

Terminal window
npx create-nx-workspace go-workspace --preset=@naxodev/gonx

This will create a new Nx workspace pre-configured with GoNx.

If you have an existing Nx workspace and want to add our plugins:

Terminal window
nx add @naxodev/gonx
Terminal window
nx g @naxodev/gonx:application my-go-app
Terminal window
nx g @naxodev/gonx:library my-go-lib

Once you have projects set up, here are the most common commands you’ll use:

Terminal window
# Build a Go application
nx build my-go-app
Terminal window
# Run a Go application
nx serve my-go-app
Terminal window
# Test a Go project
nx test my-go-app
GeneratorDescription
applicationGenerate a Go application
go-blueprintGenerate Go applications using Go Blueprint
libraryGenerate a Go library
initInitialize gonx in an existing workspace
presetPreset generator for creating a new workspace
ExecutorDescription
buildBuild a Go project
generateRun code generation using go generate
lintFormat and lint a Go project
serveRun a Go application
testRun tests of a Go project
tidyEnsures go.mod file matches a project source code
nx-release-publishLists the module in the Go registry

Need more customization? See our plugin configuration options.

GoNx supports Nx’s release process with Go’s versioning conventions. We automatically set up project names to match their directory paths, which ensures compatibility with Go’s release tagging convention (projectRoot/vx.x.x).

To configure your workspace for releasing Go modules, add a configuration like this to your nx.json:

{
"release": {
"projectsRelationship": "independent",
"projects": ["your-go-project"],
"releaseTagPattern": "{projectName}/v{version}", // important! this is the Go release tag pattern
"changelog": {
...
},
"version": {
"useLegacyVersioning": false, // important! this means that we are using the plugin version actions
...
},
}
}

Key configuration points:

  • releaseTagPattern: Set to {projectName}/v{version} to create Go-compatible tags (e.g., apps/myapp/v1.2.3)
  • projectName: With gonx, this is the full path to your project, not just the directory name

See the nx-release-publish executor docs for more information.

Thanks goes to these wonderful people (emoji key):

Nacho Vazquez
Nacho Vazquez

🐛 💻 📖 💡 🤔 🧑‍🏫 🚧 📆 👀
Wenzel
Wenzel

💻
Miguel
Miguel

💻
Miguel
Abel

💻 📖

This project is a fork of nx-go, a plugin for Nx that provides tools for building Go applications. Most credit goes to the original maintainers of nx-go - we’ve built upon their excellent foundation to modernize the plugin for the latest Nx features.

We’re also inspired by the work done by other Nx Champions:

We value community contributions and feedback. Here’s how you can get involved:

If you need help:

  1. Check the documentation
  2. Search existing GitHub issues
  3. Join our Discord community for quick questions
  4. Create a new GitHub issue for bugs or feature requests

Let’s build something amazing together! 🚀