r/codereview • u/cankutay04 • Nov 02 '26
Built a standard-library reference repo covering Go backend patterns (Concurrency, Networking, Resiliency, Memory, Architecture) — looking for code review and feedback
Hi everyone,
I’m a Computer Engineering student focusing on Go backend engineering. Rather than relying entirely on heavy third-party frameworks, I spent the last few weeks building go-backend-patterns from scratch—an educational reference repository implementing production patterns using standard library primitives and golang.org/x/sync.
Every module is tested under -race and includes a custom goroutine leak detector (internal/leaktest). The repository is structured across 5 distinct pillars:
- Concurrency (
concurrency/): Bounded worker pools with graceful drain, multi-stage pipelines, fan-out/fan-in workers,errgrouperror propagation/cancellation, andor_donechannel wrappers. - Networking (
networking/): Signal-driven graceful HTTP server shutdown, tuned HTTP client transport pools, composable HTTP middleware chaining, standardized API envelopes, and SSE streaming with client disconnect detection. - Resiliency (
resiliency/): Atomic 3-state circuit breaker FSM, token bucket rate limiting via lazy mathematical replenishment, and exponential retry backoff with Full Jitter. - Memory Performance (
memory_performance/): Reusable byte buffers withsync.PoolandmaxCapclamping to prevent memory bloat, alongside lock-free metrics usingsync/atomicarrays and static histogram buckets (0 B/op). - Architecture (
architecture/): Functional options with fail-fast validation, context-driven transaction runner (transaction_runner) with named-return panic safety, and generic Cache-Aside withsingleflightstampede mitigation andcontext.WithoutCancel.
Since I am learning independently without local peers to bounce ideas off of, I would really appreciate honest critiques on any package that catches your eye. Whether it’s idiomatic Go style, edge-case safety, or architectural trade-offs, I want to learn what can be improved.
Repo: https://github.com/Cankutay3104/go-backend-patterns
Thanks in advance to anyone who takes a look!
1
u/Jazzlike_Place_1974 Nov 02 '26
in the cache-aside with singleflight and context.WithoutCancel, watch out for unbounded upstream fetches if the downstream dependency hangs. usually you still want to attach a separate hard timeout to the detached context so a single slow call doesnt block the flight group forever.