Web for Gos
Web development in Go centres on the net/http package, which provides an HTTP server, handlers, routing and a client without external frameworks. Handlers read requests and write responses, and the database/sql package connects to databases through drivers, using prepared statements and connection pooling.
Stage: Standard Library · Part of the Go roadmap · Last reviewed 19 November 2026
What to learn in Web
- Write an http.Handler and register routes with ServeMux
- Decode a JSON request body and encode a JSON response
- Add middleware for logging and recovery by wrapping handlers
- Query PostgreSQL with database/sql and scan rows into structs
- Set server timeouts and shut down gracefully
Web interview questions
What is an http.Handler?
It is an interface with one method, ServeHTTP(ResponseWriter, *Request). Anything implementing it can serve requests, and http.HandlerFunc adapts ordinary functions. Middleware works by wrapping one handler in another.
Why set timeouts on an http.Server?
The default server has no timeouts, so slow or stalled clients can hold connections and goroutines indefinitely. Setting ReadHeaderTimeout, ReadTimeout, WriteTimeout and IdleTimeout protects resources and helps against slow-client attacks.
Where Web fits in the Go roadmap
Web belongs to the Standard Library stage (intermediate level), which takes about 20 hours. Batteries included.