The NestGo CLI provides powerful commands for project scaffolding, code generation, and development workflow.
go install github.com/nestgo/nestgo/cmd/nestgo@latestVerify installation:
nestgo --versionEnable autocompletion for faster command entry:
Bash:
echo 'source <(nestgo completion bash)' >> ~/.bashrc
source ~/.bashrcZsh:
echo 'source <(nestgo completion zsh)' >> ~/.zshrc
source ~/.zshrcFish:
nestgo completion fish | source| Command | Description |
|---------|-------------|
| nestgo new | Create a new NestGo project |
| nestgo dev | Start development server with hot-reload |
| nestgo generate | Generate code (module, controller, service) |
| nestgo doctor | Run diagnostics on your project |
| nestgo graph | Visualize module dependencies |
| nestgo lint-arch | Enforce Clean Architecture module boundaries |
| nestgo routes | Display an AST-generated Route Explorer table |
| nestgo docs:generate| Scaffold OpenAPI specs from code |
| nestgo metrics | Display project health metrics |
| nestgo build | Build for production |
Create a new NestGo project:
nestgo new my-apiOptions:
--package-manager - Choose package manager (go-modules, dep)--skip-git - Skip git initialization--template - Use a specific template (default, microservice, api)Examples:
# Create with default settings
nestgo new my-api
# Create without git init
nestgo new my-api --skip-git
# Use microservice template
nestgo new my-api --template=microserviceStart the development server with hot-reload:
nestgo devThe server will start at http://localhost:8080.
Generate code components:
nestgo generate module productsCreates:
internal/products/
└── products.module.go
nestgo generate controller productsnestgo generate service productsnestgo generate resource productsCreates controller, service, DTO, and module.
Run diagnostics to check your project setup:
nestgo doctorChecks:
Visualize module dependencies as a graph:
nestgo graphOutputs a text-based diagram showing how modules depend on each other.
Enforce Clean Architecture boundaries by detecting illegal cross-module imports:
nestgo lint-archReturns exit code 1 if a module illegally imports domain logic from an isolated sibling module.
Visualize all API endpoints currently defined in your controllers via AST inspection:
nestgo routesScans your codebase and outputs a beautiful terminal table showing Methods, Paths, and Summaries.
Automatically scaffold openapi.json from your existing NestGo AST route definitions:
nestgo docs:generateDisplay key project metrics (number of controllers, services, lines of code, etc.):
nestgo metricsBuild for production:
nestgo buildOutputs binary to ./dist/.
# Create project
nestgo new my-app
cd my-app
# Start development
nestgo dev
# Generate components
nestgo generate module users
nestgo generate controller users
nestgo generate service users
# Check setup
nestgo doctor
# View dependencies
nestgo graph
# Production build
nestgo build