I have opinions about Go web frameworks now. I did not want to have opinions. I wanted to pick something, build the thing, and move on. Instead I spent three weeks evaluating options before starting, switched frameworks once during development, and now have a production system with strong views about what worked and what did not.
This is not a benchmark post. I do not care that Fiber handles 400k requests/second in a synthetic test. I care that I can render a server-side HTML template with a dynamic nav, handle file uploads, and get useful error messages when I forget a closing brace in a template. Real usage criteria.
What I built
A cybersecurity consulting site with 1,600+ articles, full-text search via Meilisearch, a custom SEO scoring engine, PDF generation hooks, an admin interface with article CRUD, and a handful of API endpoints for search and lead capture. Server-side rendered HTML using Go's html/template. No React, no SPA. Just fast, boring HTML.
Traffic is moderate (a few thousand visits per day), but the codebase complexity is real: about 8,000 lines of Go across handlers, middleware, search integration, and a background task runner.
Gin: the safe choice I did not take
Gin is the most popular Go web framework by GitHub stars and the most likely answer when you ask "what Go framework should I use" on Reddit. It is mature, the ecosystem is large, and you will find a StackOverflow answer for almost any problem.
My issue with Gin was ergonomics for HTML rendering. Gin's template support exists, but it felt bolted on. The context type (*gin.Context) has different method names than you might expect coming from other frameworks, and the error handling model — where you call Abort() to stop handler chain execution — tripped me up repeatedly. It works, but the mental model did not click for me.
Gin also uses net/http underneath, which is the standard library. That is not a criticism — it means Gin integrates cleanly with any middleware written for net/http. But Fasthttp, which Fiber uses, is measurably faster for I/O-heavy workloads and the difference shows up in time-to-first-byte on slow connections.
I would reach for Gin if I were building a JSON API for a service that will be maintained by many developers over many years. The ecosystem and community are unmatched.
Echo: the cleanest API
Echo has the best-designed API of the three. Routes are clean, the middleware interface is simple, context methods are named sensibly, and the error handling model (returning errors from handlers, which Echo routes to a centralized error handler) is genuinely good.
// Echo error handling — clean and centralized
e.HTTPErrorHandler = func(err error, c echo.Context) {
code := http.StatusInternalServerError
message := "Internal Server Error"
if he, ok := err.(*echo.HTTPError); ok {
code = he.Code
message = fmt.Sprintf("%v", he.Message)
}
c.JSON(code, map[string]string{"error": message})
}
Echo's template rendering also requires a small adapter (Echo uses its own Renderer interface rather than html/template directly), but the adapter is 10 lines of code and well-documented.
Where I found Echo lacking: the community is smaller than Gin, and when I hit an unusual problem with template caching behavior during development, I could not find anyone who had solved exactly the same thing. I ended up reading Echo source code, which is fine but not ideal when you are trying to move fast.
Fiber: what I chose and why
I chose Fiber. The primary reason was familiarity: Fiber's API is intentionally modeled after Express.js, and I had spent years building things with Express. The route handler signature, the middleware pattern, the way you access request parameters — all of it mapped onto existing muscle memory.
// Fiber route handler — the middleware chain feels natural
func SetupRoutes(app *fiber.App, db *sql.DB, meili *meilisearch.Client) {
// Middleware stack
app.Use(logger.New())
app.Use(compress.New())
app.Use(limiter.New(limiter.Config{
Max: 100,
Expiration: 1 * time.Minute,
}))
// Public routes
app.Get("/", handlers.HomePage)
app.Get("/articles/:slug", handlers.ArticlePage)
app.Get("/api/search", handlers.SearchArticles)
// Admin group with auth middleware
admin := app.Group("/admin", middleware.AuthRequired)
admin.Get("/", handlers.AdminDashboard)
admin.Post("/articles", handlers.CreateArticle)
admin.Put("/articles/:id", handlers.UpdateArticle)
admin.Delete("/articles/:id", handlers.DeleteArticle)
}
Fiber's html/template integration is first-class. You pass a template engine to fiber.Config and it handles caching, reloading in development, and template function maps without needing adapters.
engine := html.New("./templates", ".html")
engine.AddFunc("formatDate", func(t time.Time) string {
return t.Format("2 January 2006")
})
app := fiber.New(fiber.Config{
Views: engine,
ViewsLayout: "layouts/main",
})
Fasthttp underneath means lower memory allocation per request, which matters for a server with 4GB of RAM serving both the web application and Meilisearch simultaneously.
The honest criticism of Fiber
Fiber has a real gotcha that has bitten me twice: you cannot pass a *fiber.Ctx to a goroutine.
Fiber reuses context objects for performance (Fasthttp's zero-allocation design). If you start a goroutine inside a handler and pass the context to it, by the time the goroutine runs, the context has been recycled for another request. You get corrupted data silently.
// This will corrupt data — ctx is reused after handler returns
app.Post("/articles", func(ctx *fiber.Ctx) error {
go func() {
processInBackground(ctx) // WRONG — ctx is invalid here
}()
return ctx.SendStatus(202)
})
// Correct — copy what you need before spawning the goroutine
app.Post("/articles", func(ctx *fiber.Ctx) error {
bodyBytes := make([]byte, len(ctx.Body()))
copy(bodyBytes, ctx.Body())
userID := ctx.Locals("user_id").(int)
go func() {
processInBackground(bodyBytes, userID) // safe
}()
return ctx.SendStatus(202)
})
This is documented, but it is the kind of thing that only becomes obvious after you spend an afternoon debugging a race condition that looks completely unrelated. If you are building something with heavy goroutine usage from request handlers, this is a significant ergonomic cost.
The actual decision factors
| Factor | Gin | Echo | Fiber |
|---|---|---|---|
| HTML template integration | Adequate | Good (with adapter) | Excellent |
| Express-like API | No | Somewhat | Yes |
| Community size | Large | Medium | Medium |
| Error handling model | Confusing | Best | Good |
| Goroutine safety | Safe | Safe | Careful required |
| Performance (Fasthttp) | No | No | Yes |
For a server-side rendered content platform with moderate traffic and one developer maintaining it: Fiber. For a team JSON API: Gin. For clean code you are proud of: Echo.
The article library running on this stack currently serves 1,600+ pieces of content. Fiber has not been the bottleneck once. The database has.
I run AYI NEDJIMI Consultants, a cybersecurity consulting firm. We publish security hardening checklists for FortiGate, Palo Alto, Active Directory, and more — free PDF and Excel.
Top comments (0)