GoNest brings NestJS's battle-tested architecture to Go. Modules, dependency injection, guards, pipes, interceptors — all expressed idiomatically for the Go ecosystem.
func main() {
app := gonest.Create(AppModule)
app.UseGlobalPipes(gonest.NewValidationPipe())
app.EnableCors()
app.Listen(":3000")
} Automatic constructor-based DI with singleton, request, and transient scopes. Interface bindings, token providers, and forward references.
Declarative route protection with JWT authentication, role-based access control, sessions, and rate limiting out of the box.
Self-contained modules with imports, exports, and dynamic configuration. Lazy loading, configurable module builder, and ForRoot/ForFeature patterns.
Middleware, guards, interceptors, pipes, and exception filters compose into a powerful, predictable request pipeline with lifecycle hooks.
TCP, gRPC, NATS, Redis, Kafka, RabbitMQ, and MQTT transports. Message patterns, hybrid HTTP+microservice mode, and custom transports.
Auto-generated OpenAPI documentation with Swagger UI. Built-in GraphQL engine with playground and federation support.
Cron jobs, intervals, and timeouts. In-memory job queues with workers, retries, and configurable concurrency.
SQL module for Postgres, MySQL, SQLite, and SQL Server. MongoDB module. Generic repository pattern with pagination.
Cookie-based sessions with pluggable stores. Built-in CORS support. API versioning via URI, header, or media type.
Server-side HTML rendering with Go templates. File uploads with validation. Streaming file downloads. Static file serving.
Runtime introspection of modules, providers, and dependency graphs. Interactive REPL for debugging. Serialized graph export.
The core framework uses only the Go standard library. Optional modules add external dependencies as needed.
Controllers, services, guards, pipes, modules — all wired together by the DI container.
type CatsController struct {
service *CatsService
}
func NewCatsController(service *CatsService) *CatsController {
return &CatsController{service: service}
}
func (c *CatsController) Register(r gonest.Router) {
r.Prefix("/cats")
r.UseGuards(NewRolesGuard)
r.Get("/", c.findAll)
r.Post("/", c.create).
SetMetadata("roles", []string{"admin"})
r.Get("/:id", c.findOne).
Pipes(gonest.NewParseIntPipe("id"))
}