Quick Start
GoNx
A modern Nx plugin for Go/Golang development
GoNx - A very opinionated Nx plugin for Go/Golang
The philosophy of gonx is to generate a non-invasive tooling to work with Go and Nx, heavily relying on inferred tasks and modern Nx features.
Prerequisites
Section titled “Prerequisites”Before getting started, ensure you have:
- Node.js (version 18 or later)
- npm, pnpm, or yarn package manager
- Nx CLI (
npm install -g nx
ornpm install -g @nx/cli
)
For GoNx specifically:
- Go (stable version) installed on your machine
Compatibility
Section titled “Compatibility”gonx is compatible with the following Nx versions:
Nx Version | gonx Version |
---|---|
21.x | >=^1.0.0 <=^2.0.0 |
Getting started
Section titled “Getting started”Option 1: Create a New Workspace with GoNx
Section titled “Option 1: Create a New Workspace with GoNx”If you want to start a new workspace focused on Go development:
npx create-nx-workspace go-workspace --preset=@naxodev/gonx
This will create a new Nx workspace pre-configured with GoNx.
Option 2: Add to Existing Workspace
Section titled “Option 2: Add to Existing Workspace”If you have an existing Nx workspace and want to add our plugins:
Add GoNx
Section titled “Add GoNx”nx add @naxodev/gonx
Your First Project
Section titled “Your First Project”Create a Go Application
Section titled “Create a Go Application”nx g @naxodev/gonx:application my-go-app
Create a Go Library
Section titled “Create a Go Library”nx g @naxodev/gonx:library my-go-lib
Common Commands
Section titled “Common Commands”Once you have projects set up, here are the most common commands you’ll use:
Building Projects
Section titled “Building Projects”# Build a Go applicationnx build my-go-app
Running Projects
Section titled “Running Projects”# Run a Go applicationnx serve my-go-app
Testing Projects
Section titled “Testing Projects”# Test a Go projectnx test my-go-app
Generators & executors
Section titled “Generators & executors”Generators
Section titled “Generators”Generator | Description |
---|---|
application | Generate a Go application |
go-blueprint | Generate Go applications using Go Blueprint |
library | Generate a Go library |
init | Initialize gonx in an existing workspace |
preset | Preset generator for creating a new workspace |
Executors
Section titled “Executors”Executor | Description |
---|---|
build | Build a Go project |
generate | Run code generation using go generate |
lint | Format and lint a Go project |
serve | Run a Go application |
test | Run tests of a Go project |
tidy | Ensures go.mod file matches a project source code |
nx-release-publish | Lists the module in the Go registry |
Need more customization? See our plugin configuration options.
Release Configuration
Section titled “Release Configuration”GoNx supports Nx’s release process with Go’s versioning conventions. We automatically set up project names to match their directory paths, which ensures compatibility with Go’s release tagging convention (projectRoot/vx.x.x
).
To configure your workspace for releasing Go modules, add a configuration like this to your nx.json
:
{ "release": { "projectsRelationship": "independent", "projects": ["your-go-project"], "releaseTagPattern": "{projectName}/v{version}", // important! this is the Go release tag pattern "changelog": { ... }, "version": { "useLegacyVersioning": false, // important! this means that we are using the plugin version actions ... }, }}
Key configuration points:
releaseTagPattern
: Set to{projectName}/v{version}
to create Go-compatible tags (e.g.,apps/myapp/v1.2.3
)projectName
: With gonx, this is the full path to your project, not just the directory name
See the nx-release-publish executor docs for more information.
Contributors
Section titled “Contributors”Thanks goes to these wonderful people (emoji key):
Nacho Vazquez 🐛 💻 📖 💡 🤔 🧑🏫 🚧 📆 👀 |
Wenzel 💻 |
Miguel 💻 |
Abel 💻 📖 |
Acknowledgements
Section titled “Acknowledgements”This project is a fork of nx-go, a plugin for Nx that provides tools for building Go applications. Most credit goes to the original maintainers of nx-go - we’ve built upon their excellent foundation to modernize the plugin for the latest Nx features.
We’re also inspired by the work done by other Nx Champions:
Community
Section titled “Community”We value community contributions and feedback. Here’s how you can get involved:
- Discord: Join our Discord Server for real-time discussions
- GitHub: Contribute to our open source repository
- Issues: Report bugs and request features through GitHub Issues
Getting Support
Section titled “Getting Support”If you need help:
- Check the documentation
- Search existing GitHub issues
- Join our Discord community for quick questions
- Create a new GitHub issue for bugs or feature requests
Let’s build something amazing together! 🚀