Interview Q&A · questions with model answers
Go Web Frameworks Interview Questions
Ordered by how often they're asked. Most-asked answers are free to read in full; members see every answer and can rate their confidence on each.
-
Most asked How do you implement graceful shutdown for a Go HTTP server?
Listen for SIGINT/SIGTERM (signal.NotifyContext), then call server.Shutdown(ctx) with a timeout: it stops accepting new connections and waits for in-flight requests to finish before returning.
-
Most asked How do you pass request-scoped values (like the current user) through middleware in Go?
Store them in the request's context with context.WithValue, using an unexported key type to avoid collisions, pass r.WithContext(ctx) to the next handler, and read them with a typed helper.
-
Most asked How do you design consistent error responses in a Go API?
Define one API error type (status, machine-readable code, message, optional field errors), one function that writes it, and map domain errors to it in one place; unexpected errors become a generic…