r/codereview • • 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:

  1. Concurrency (concurrency/): Bounded worker pools with graceful drain, multi-stage pipelines, fan-out/fan-in workers, errgroup error propagation/cancellation, and or_done channel wrappers.
  2. 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.
  3. Resiliency (resiliency/): Atomic 3-state circuit breaker FSM, token bucket rate limiting via lazy mathematical replenishment, and exponential retry backoff with Full Jitter.
  4. Memory Performance (memory_performance/): Reusable byte buffers with sync.Pool and maxCap clamping to prevent memory bloat, alongside lock-free metrics using sync/atomic arrays and static histogram buckets (0 B/op).
  5. Architecture (architecture/): Functional options with fail-fast validation, context-driven transaction runner (transaction_runner) with named-return panic safety, and generic Cache-Aside with singleflight stampede mitigation and context.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!

3 Upvotes

3 comments sorted by

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.