What problem does it solve?
It helps prevent common failures in concurrent Go programs—goroutine leaks, race conditions, incorrect channel ownership, and broken cancellation/error handling—by enforcing safe structured-concurrency patterns.
Core Features & Use Cases
- Structured concurrency guardrails: ensures every goroutine has a clear shutdown path (typically via context cancellation or channel closure semantics).
- Safe channel ownership and usage: enforces “sender closes, receiver reads,” uses channel direction types, and avoids sending shared mutable pointers.
- Correct primitives selection: guides decisions between channels, mutexes, RWMutex, atomics, sync.Map, singleflight, and errgroup/WaitGroup.
- Common anti-pattern detection: flags time.After-in-select-loop churn, missing ctx.Done() in selects, unbounded goroutine spawning, and mutex/channel misuse.
- Use case: when building a message-processing pipeline (fan-out/fan-in) for an online service, apply these rules to guarantee workers stop on cancellation, propagate first errors correctly, and avoid hidden shared memory.
Quick Start
Use the golang-concurrency skill to review and fix a Go service change that adds goroutines and channels to a request handler, ensuring it exits cleanly on context cancellation and has correct channel closing and error propagation.