Library Generator
nx g @naxodev/gonx:library my-go-lib
Options
Section titled “Options”Option | Type | Default | Description |
---|---|---|---|
name | string | null | Name of the Go library |
directory | string | *required | The directory of the new library |
tags | string | null | Add tags to the library (used for linting) |
skipFormat | boolean | false | Skip formatting files |
Examples
Section titled “Examples”Generate a library in the root
Section titled “Generate a library in the root”nx g @naxodev/gonx:library my-go-lib
Generate a library in a specific directory
Section titled “Generate a library in a specific directory”nx g @naxodev/gonx:library libs/my-go-lib
Generate a library with tags
Section titled “Generate a library with tags”[!NOTE] Tags will only work when the project was created with a project.json file
nx g @naxodev/gonx:library my-go-lib --tags="json yaml"
Output
Section titled “Output”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