Concurrency model: goroutines — green threads, since Go 1.0. You write blocking code; the runtime multiplexes onto OS threads. No async/await, so no “coloured function” split in the ecosystem. → runtime models

~11,000 words across 6 notes. [reference] — no Go service in this vault yet. Assumes the Go course and the backend course; these notes cover only what those don’t.

The thing that makes Go’s HTTP ecosystem different: everything is http.Handler, one interface with one method. A Chi router, a Gin engine, your own function, and every middleware in the ecosystem all satisfy it — so they interoperate without adapters. Most ecosystems have framework-specific middleware that can’t be reused; Go got composability by agreeing on the narrowest possible interface early.

Reading order

  1. `net/http` in Depth — [Intermediate] — the Handler interface, Go 1.22 routing, and the server configuration that separates a toy from production. http.ListenAndServe has no timeouts
  2. Middleware as Composition — [Intermediate] — func(Handler) Handler, the essential middleware, and why wrapping ResponseWriter breaks Flusher and Hijacker
  3. Routers: Chi and Gin — [Intermediate] — what a router still adds after Go 1.22, and the lock-in question
  4. Structuring a Go Service — [Intermediate] — DI without a container, handlers as methods, and error→status mapping in one place
  5. Database Access — [Intermediate] — database/sql, the pool settings that decide whether you survive load, and why Go is sceptical of ORMs
  6. Testing and Production — [Intermediate] — httptest, fakes without a mocking framework, observability, and the container gotchas

The stdlib-is-enough argument, honestly

Go 1.22 gave http.ServeMux method matching and path wildcards, which removed most of the reason to take a router dependency. net/http is a production HTTP server — not a toy you replace.

What the stdlib still doesn’t give you: route groups with shared middleware, a chaining helper, correct ResponseWriter wrapping, and request validation. Each is 10–50 lines you write once.

So: start with the stdlib, add Chi when route grouping starts hurting. The migration is mechanical because Chi uses the identical types. That deferrable framework decision is unusual — in most ecosystems it’s load-bearing and early.

The framework table

stdlibChiGinEchoFiber
net/http compatible✅✅partialpartial❌
Route groups❌✅✅✅✅
Binding + validation❌❌✅✅✅
Lock-innonenonerealrealtotal

Fiber is built on fasthttp and is not net/http compatible — you lose the entire middleware, tracing and metrics ecosystem for throughput you almost certainly don’t need.

What Go does badly here

  • No request validation in the stdlib. You write it, or take go-playground/validator, or use Gin’s binding
  • No dependency injection. Deliberate, and it means wiring is explicit and verbose
  • ResponseWriter has no status getter — a genuine design wart, and the reason every logging middleware wraps it
  • ORMs are weak by comparison. sqlc is the good answer; GORM works and generates SQL you didn’t write
  • Error handling is manual. No @ControllerAdvice; you write the error→status switch. More code, and no framework knowledge needed to read it
↑ Back to frameworks/ — Ways of Building a Backend