Skip to content

Library Generator

Terminal window
nx g @naxodev/gonx:library my-go-lib
OptionTypeDefaultDescription
namestringnullName of the Go library
directorystring*requiredThe directory of the new library
tagsstringnullAdd tags to the library (used for linting)
skipFormatbooleanfalseSkip formatting files
Terminal window
nx g @naxodev/gonx:library my-go-lib

Generate a library in a specific directory

Section titled “Generate a library in a specific directory”
Terminal window
nx g @naxodev/gonx:library libs/my-go-lib

[!NOTE] Tags will only work when the project was created with a project.json file

Terminal window
nx g @naxodev/gonx:library my-go-lib --tags="json yaml"

The generator creates a Go library with the following structure:

my-go-lib/
├── go.mod
├── go.sum
├── my-go-lib.go
└── my-go-lib.go_test.go
  • Unlike the original nx-go, gonx does not generate a project.json file
  • Uses inferred tasks, so you can immediately use nx build, nx test, etc.
  • Works with both single and multi-module Go workspace configurations
  • Integrated with Nx release system for version management