Go is a strong choice for web development: the standard library's net/http package can run a production-grade HTTP server without any framework, goroutines make handling many concurrent requests cheap, and a Go program builds to a single static binary that is easy to deploy. It is widely used for APIs, microservices and network services.
Since Go 1.22 the standard router supports HTTP methods and path parameters, so many services no longer need a third-party router.
The net/http package provides servers, clients, routing, cookies, file serving and TLS. This server uses the Go 1.22+ pattern syntax with a method and a path parameter.
Before Go 1.22, ServeMux matched only paths, so frameworks were used for methods and parameters. Check your Go version if the pattern syntax does not compile.
The server runs each request in its own goroutine. Goroutines are lightweight, so thousands of concurrent connections are normal. You can start your own goroutines for parallel work, such as calling two backends at once, using context for cancellation and deadlines.
r.Context() is cancelled when the client disconnects, so downstream work stops early. fetchProfile and fetchOrders stand for your own functions.
Middleware in Go is a function that wraps an http.Handler.
log/slog (Go 1.21 and later) gives structured logging. Other useful packages include:
html/template for HTML rendering with contextual auto-escaping against XSS.encoding/json for APIs.net/http/httptest for testing handlers without a network.crypto/tls for HTTPS, and net/http/pprof for profiling.You can build most services with the standard library. Frameworks add conveniences.
| Option | Typical use |
|---|---|
net/http with ServeMux | APIs and services with simple routing |
| Gin | Fast JSON APIs with middleware and binding |
| Echo | Similar scope, with built-in helpers |
| Chi | A small router compatible with net/http handlers |
| Fiber | Express-style API, built on fasthttp (not net/http compatible) |
Prefer routers that use standard http.Handler, because middleware and tools then interoperate. Pick a framework for team familiarity, not because plain Go cannot handle the task.
Go compiles to a single binary, which keeps containers small.
Set timeouts on http.Server (ReadHeaderTimeout, ReadTimeout, WriteTimeout, IdleTimeout) in production, and call srv.Shutdown(ctx) on a signal for graceful shutdown. A server without timeouts can be held open by slow clients.
Go suits APIs, microservices, proxies, real-time services and command-line tools around web systems. For server-rendered sites with heavy CMS features, or when you need a large batteries-included framework with an ORM and admin panel, ecosystems like Django, Rails or Laravel give you more out of the box. Go's ecosystem for templates and full-stack frameworks is smaller, though tools like templ and HTMX-style approaches are common.
No. net/http covers servers, routing (with methods and path values since Go 1.22), cookies and TLS. Use a framework only if its extras help your team.
Yes. It has built-in JSON support, fast startup, low memory use and straightforward concurrency, which is why it is common for REST and gRPC services.
The server starts a goroutine per connection or request, and the runtime schedules goroutines across CPU cores, so you write ordinary blocking code.
Start with the standard library. If you want more structure, Gin, Echo and Chi are common choices. Chi stays closest to net/http.
Go supports web development through a capable standard library, built-in concurrency and easy deployment. Use net/http with Go 1.22+ routing for most services, add middleware and slog, set server timeouts, and choose a framework only when you need its extras.