Skip to content

Quick start

import { Steps } from ‘@astrojs/starlight/components’;

Create a Go application with Nx, then run, test, and build it using targets that gonx infers from go.mod.

  • Node.js 20+ and an Nx 23.x workspace
  • Go — a stable release (1.18+ for multi-module workspaces)

gonx 3.x targets Nx 23.x:

Nx versiongonx version
23.x3.x
1. **Create a workspace with the gonx preset** ```bash npx create-nx-workspace go-workspace --preset=@naxodev/gonx ``` This scaffolds an Nx workspace with gonx registered and a starter Go project. If you already have a workspace, install gonx into it instead: ```bash npx nx add @naxodev/gonx ```
  1. Create a Go application

    cd go-workspace
    npx nx g @naxodev/gonx:application my-go-app

    The generator creates a Go project with a package main entry point. gonx detects the go.mod and infers build, serve, test, lint, tidy, and generate targets. Pass --template to choose standard, cli, or tui. See the application generator guide for all options.

  2. Run the application

    npx nx serve my-go-app

    The serve target runs go run from the project root. See the serve executor guide.

  3. Test the project

    npx nx test my-go-app

    The test target runs go test. See the test executor guide.

  4. Build the project

    npx nx build my-go-app

    The build target compiles an executable. See the build executor guide.

List the projects Nx detected and the targets inferred for your application:

npx nx show projects
npx nx show project my-go-app

nx show project lists the build, serve, test, lint, tidy, and generate targets with no project.json file. Run npx nx build my-go-app a second time to confirm caching — the second run is served from the Nx cache.