🐹 Go Backend Development

Go philosophy

Prefer the stdlib + small libraries over big frameworks. Explicit over magic. This is the opposite mindset from Spring, and knowing both makes you a stronger engineer.

Stack choices (learn the default well; know the alternatives)

ConcernDefaultAlternatives
HTTP routingnet/http (1.22+ patterns) or chigin, echo, fiber
DB driverpgxdatabase/sql
Queriessqlc (SQL → type-safe Go)GORM (know it, but avoid in hot paths), sqlx, ent, bun
Migrationsgoose or golang-migrate / atlas
Configenv + caarlos0/env or koanfviper
Logginglog/slogzap, zerolog
Validationgo-playground/validator
gRPCgrpc-go + buf / connect-go
GraphQLgqlgen
Kafkafranz-goconfluent-kafka-go, segmentio/kafka-go
Redisgo-redisrueidis
Testingstdlib + testify + testcontainers-go
ObservabilityOpenTelemetry Go SDK + Prometheus client
DImanual constructor wiringwire, fx

Checklist

  • Project structure: cmd/, internal/ (by domain), not “Java-style” layered packages
  • Handler → service → repository with interfaces at the consumer side
  • Middleware: logging, recovery, request ID, auth (JWT validation via JWKS), CORS, rate limiting
  • Graceful shutdown (signal.NotifyContext, server.Shutdown)
  • Timeouts everywhere (http.Server Read/Write/Idle timeouts, context.WithTimeout for DB/HTTP calls)
  • Transactions with pgx; optimistic locking; SELECT … FOR UPDATE SKIP LOCKED job queues
  • Errors → HTTP status mapping; problem+json
  • Health/readiness endpoints; Prometheus metrics; pprof endpoint (protected)
  • Integration tests with testcontainers-go

🧪 Labs (🟢 warm-up → 🟡 core → 🔴 hard → ⚫ boss)

  • 🟢 chi + pgx + sqlc + slog service with graceful shutdown
  • 🟡 Middleware chain: request ID, logging, recovery, auth, rate limit (Decorator)
  • 🔴 orbit-llm-gateway: provider adapters, SSE streaming passthrough, Lua quotas, fallback
  • 🔴 A SKIP LOCKED job queue with leases + heartbeats
  • ⚫ k6 + pprof: find and remove the top hotspot; show before/after flame graphs

🧠 Cognitive tasks

  • Predict → verify: gateway overhead at p99 with 500 concurrent streams
  • Trade-off debate: sqlc vs GORM for the engine’s hot paths

🛰️ Orbit integration

  • orbit-engine, orbit-worker, orbit-llm-gateway, orbit-hooks, and orbit-stream

Go deeper

Resources

  • Let’s Go + Let’s Go Further (Alex Edwards) ⭐ · 100 Go Mistakes ⭐
  • sqlc.dev, pgx docs, buf.build docs, connectrpc.com
  • Ardan Labs Service repo (production service structure)