NestGo — a NestJS-Style Web Framework for Go
NestGo brings the architecture that made NestJS popular — controllers, dependency injection, guards, interceptors, pipes, and exception filters — to Go, while staying true to Go’s philosophy: explicit code, compile-time safety, and a single static binary. Use it to build REST APIs, microservices, and production backend services in Golang without inventing your own project structure.
go get github.com/ashrafAli23/nestgo
go get github.com/ashrafAli23/nestgo-gin-adapter # or nestgo-fiber-adapter
Why NestGo?
- Familiar architecture, idiomatic Go — if you know NestJS, you already know where everything goes. No decorators or runtime reflection on the hot path: NestGo uses Go generics for type-safe parameter extraction.
- Swap HTTP engines in one line — the core is interfaces only. Run on Gin or Fiber and switch adapters without touching a single handler.
- Dependency injection is optional — plain constructors with the
apppackage, or uber/fx modules withdi; same behavior either way. - Production middleware included — CORS, Helmet, rate limiting, CSRF, request ID, distributed tracing, timeouts, ETag, idempotency, body limits, uploads, compression, and structured request logging.
- Production-ready lifecycle — graceful shutdown on SIGTERM, TLS, health and readiness probes for Kubernetes, and pluggable structured logging.
A complete endpoint in a few lines
type UserController struct{}
func (c *UserController) Prefix() string { return "/users" }
func (c *UserController) RegisterRoutes(r core.Router) {
r.GET("/:id", core.Handle2(core.RCtx(), core.PInt64("id"), c.GetByID))
r.POST("/", core.HandleC1(core.B[CreateUserDTO](), c.Create))
}
// Typed parameters are extracted and validated for you — the Go
// equivalent of NestJS's @Param() and @Body() decorators.
func (c *UserController) GetByID(ctx context.Context, id int64) (any, error) {
return map[string]any{"id": id}, nil
}
func (c *UserController) Create(ctx core.Context, dto *CreateUserDTO) error {
return ctx.JSON(201, dto)
}
Wire it up with dependency injection and run:
app := di.NewApp(config, ginadapter.New,
fx.Module("users", fx.Provide(di.AsController(NewUserController))),
)
app.Run()
Explore the documentation
| Start here | Build features | Run in production |
|---|---|---|
| Getting Started | Guards · Interceptors | Production Guide |
| Controllers & Routing | Pipes · Exception Filters | Middleware Reference |
| Type-Safe Handlers | Validation & Errors | Adapters: Gin & Fiber · Writing an Adapter |
| Application Without DI · Dependency Injection | API Versioning · Server-Sent Events | FAQ |
Coming from TypeScript? Read NestGo vs NestJS for a concept-by-concept mapping.
Project modules
| Module | Purpose |
|---|---|
nestgo | Core framework: interfaces, middleware, DI |
nestgo-gin-adapter | Gin HTTP engine adapter (net/http based) |
nestgo-fiber-adapter | Fiber v3 HTTP engine adapter (fasthttp based) |
nestgo-validator | Struct-tag validation for DTOs |
NestGo requires Go 1.25.14 or later and is MIT licensed.