golang-concurrency-patterns

Installation
SKILL.md

Go Concurrency Patterns (Production)

Overview

Go concurrency scales when goroutine lifetimes are explicit, cancellation is propagated with context.Context, and shared state is protected (channels or locks). Apply these patterns to build reliable services and avoid common failure modes: goroutine leaks, deadlocks, and data races.

Quick Start

Default building blocks

  • Use context to drive cancellation and deadlines.
  • Use errgroup.WithContext for fan-out/fan-in with early abort.
  • Bound concurrency (avoid unbounded goroutines) with a semaphore or worker pool.
  • Prefer immutable data; otherwise protect shared state with a mutex or make a single goroutine the owner.

Avoid

  • Fire-and-forget goroutines in request handlers.
  • time.After inside hot loops.
  • Closing channels from the receiver side.
  • Sharing mutable variables across goroutines without synchronization.
Related skills
Installs
214
GitHub Stars
43
First Seen
Jan 23, 2026