Go Blueprint Generator
The Go Blueprint binary is included with this package, so no additional installation is required.
nx g @naxodev/gonx:go-blueprint my-go-app
The generator will prompt you to select:
- Web framework
- Database driver
- Git handling preference
- Advanced features (optional)
Options
Section titled “Options”Option | Type | Default | Description |
---|---|---|---|
directory | string | *required | The directory of the new application |
name | string | null | The name of the application |
tags | string | null | Add tags to the project (used for linting) |
skipFormat | boolean | false | Skip formatting files |
addGoDotWork | boolean | false | Add this project to go.work file |
framework | string | *required | Web framework to use |
driver | string | *required | Database driver to use |
git | string | *required | Git handling preference |
feature | array | [] | Advanced features to include |
Framework Options
Section titled “Framework Options”chi
- Chi routergin
- Gin web frameworkfiber
- Fiber web frameworkgorilla/mux
- Gorilla Mux routerhttprouter
- HttpRouterstandard-library
- Go standard libraryecho
- Echo web framework
Database Driver Options
Section titled “Database Driver Options”mysql
- MySQL databasepostgres
- PostgreSQL databasesqlite
- SQLite databasemongo
- MongoDBredis
- Redisscylla
- ScyllaDBnone
- No database
Git Options
Section titled “Git Options”commit
- Initialize git and commit changesstage
- Initialize git and stage changesskip
- Skip git initialization
Advanced Features
Section titled “Advanced Features”react
- React frontend integration (⚠️ Not recommended - see Frontend Integration below)htmx
- HTMX integrationgithubaction
- GitHub Actions workflowwebsocket
- WebSocket supporttailwind
- Tailwind CSSdocker
- Docker configuration
Examples
Section titled “Examples”Basic Usage with Prompts
Section titled “Basic Usage with Prompts”nx g @naxodev/gonx:go-blueprint my-api
This will prompt you to select all required options interactively.
Specify All Options
Section titled “Specify All Options”nx g @naxodev/gonx:go-blueprint my-api \ --framework=gin \ --driver=postgres \ --git=commit \ --feature=docker,githubaction
Generate in Specific Directory
Section titled “Generate in Specific Directory”nx g @naxodev/gonx:go-blueprint apps/my-api \ --framework=fiber \ --driver=mysql \ --git=stage
Add to Go Workspace
Section titled “Add to Go Workspace”nx g @naxodev/gonx:go-blueprint my-service \ --framework=chi \ --driver=none \ --git=skip \ --addGoDotWork=true
Output
Section titled “Output”The generator creates a fully-featured Go application based on your selections. The exact structure depends on the chosen framework and features, but typically includes:
my-go-app/├── main.go├── go.mod├── go.sum├── handlers/├── models/├── database/├── static/└── ... (additional files based on selected features)
Integration with Nx
Section titled “Integration with Nx”After generation, you can use all standard Nx commands:
# Build the applicationnx build my-go-app
# Run the applicationnx serve my-go-app
# Run testsnx test my-go-app
# Lint the codenx lint my-go-app
# Manage dependenciesnx tidy my-go-app
Frontend Integration
Section titled “Frontend Integration”Recommended Approach
Section titled “Recommended Approach”Instead of using Go Blueprint’s frontend features, create separate frontend projects using Nx’s native generators:
# Generate your Go API firstnx g @naxodev/gonx:go-blueprint my-api --framework=gin --driver=postgres --git=skip
# Then generate a separate frontend projectnx g @nx/react:app frontend --directory=apps/frontend
# Or use other Nx frontend generatorsnx g @nx/angular:app frontend --directory=apps/frontendnx g @nx/vue:app frontend --directory=apps/frontend
Benefits of Separate Projects
Section titled “Benefits of Separate Projects”- ✅ Proper Nx project graph detection and dependency tracking
- ✅ Independent build, test, and deployment pipelines
- ✅ Better separation of concerns
- ✅ Full access to Nx’s frontend tooling and optimizations
- ✅ Easier to scale and maintain
Example Workspace Structure
Section titled “Example Workspace Structure”my-workspace/├── apps/│ ├── my-api/ # Go API (generated with go-blueprint)│ │ ├── main.go│ │ └── go.mod│ └── frontend/ # React/Angular/Vue app (generated with Nx)│ ├── src/│ └── package.json└── nx.json
- Go Blueprint binary is bundled with this package
- Uses Nx’s inferred tasks, so no project.json file is generated
- Follows gonx’s philosophy of keeping non-JS monorepos pure
- All Go Blueprint options are mapped to provide a seamless integration experience
Troubleshooting
Section titled “Troubleshooting”Generation Fails
Section titled “Generation Fails”If generation fails:
- Check that the target directory doesn’t already exist
- Ensure you have write permissions to the target location
- Verify all required options are provided
- Check Go Blueprint documentation for framework-specific requirements