Skip to content

Library generator

Generates a Go library under the given directory and registers it as an Nx project through the gonx inference plugin. Aliased as lib.

nx g @naxodev/gonx:library <directory>
OptionTypeDefaultDescription
directorystringrequiredDirectory of the new library. Taken from the first positional argument.
namestring-Name of the library. Must match ^[a-zA-Z][^:]*$.
tagsstring-Tags to add to the library (used for linting).
skipFormatbooleanfalseSkip formatting files.
  • Runs the init generator first to register the inference plugin in nx.json.
  • Always creates a go.mod for the project. Adds the project to go.work when a Go workspace is present.
  • Inferred targets for libraries: test, lint, tidy, generate, nx-release-publish. Libraries do not infer build or serve.