Generate Executor
nx run my-go-app:generate
Note: Use
nx run <project>:generate
instead ofnx generate <project>
to avoid conflicts with Nx’s native generator commands.
Options
Section titled “Options”Option | Type | Default | Description |
---|---|---|---|
env | object | - | Environment variables to set when running the executor |
flags | string[] | - | Flags to pass to the go generate command |
Default Inferred
Section titled “Default Inferred”{ "executor": "@naxodev/gonx:generate", "cache": true, "dependsOn": ["^generate"], "inputs": ["{projectRoot}/go.mod", "{projectRoot}/go.sum", "{projectRoot}/**/*.{go}"]}
Examples
Section titled “Examples”Basic code generation
Section titled “Basic code generation”nx run my-go-app:generate
Generate with verbose output
Section titled “Generate with verbose output”nx run my-go-app:generate --flags=-v
Generate with multiple flags
Section titled “Generate with multiple flags”nx run my-go-app:generate --flags=-v --flags=-x
Generate with custom environment variables
Section titled “Generate with custom environment variables”nx run my-go-app:generate --env.GOOS=linux --env.GOARCH=amd64
- The generate executor is cacheable, so subsequent runs with the same inputs will be faster
- Uses the official
go generate
command in the background - The generate executor automatically runs before build and test operations due to dependency configuration
- The command searches for
//go:generate
directives in all Go files within the project and its subdirectories - Generated files should be committed to version control if they are needed for builds
- The executor runs
go generate ./...
to process all packages in the project tree - Important: Always use
nx run <project>:generate
syntax to avoid conflicts with Nx’snx generate
command for generators