Skip to content

Application Generator

Terminal window
nx g @naxodev/gonx:application my-go-app
OptionTypeDefaultDescription
namestringnullName of the Go application
directorystring*requiredThe directory of the new application
templatestandard | cli | tuistandardThe template of application to generate
tagsstringnullAdd tags to the application (used for linting)
skipFormatbooleanfalseSkip formatting files
Terminal window
nx g @naxodev/gonx:application my-go-app
Terminal window
nx g @naxodev/gonx:application my-cli-app --template=cli
Terminal window
nx g @naxodev/gonx:application my-tui-app --template=tui

Generate an application in a specific directory

Section titled “Generate an application in a specific directory”
Terminal window
nx g @naxodev/gonx:application apps/my-go-app

or

Terminal window
nx g @naxodev/gonx:application --name=go-app --directory=apps/my-go-app

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

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

The generator creates different structures based on the application template:

my-go-app/
├── main.go
├── main_test.go
└── go.mod
my-cli-app/
├── main.go
├── main_test.go
├── go.mod
└── cmd/
├── root.go
├── version.go
└── cmd_test.go
my-tui-app/
├── main.go
├── main_test.go
├── go.mod
├── cmd/
└── root.go
└── internal/
└── models/
├── model.go
├── model_test.go
└── styles/
├── styles.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 serve, etc.
  • CLI applications use Cobra for professional command-line interfaces
  • TUI applications use Bubble Tea and Lipgloss for interactive terminal UIs
  • For CLI and TUI apps, run nx tidy <app-name> after generation to download dependencies