Skip to content
bobmatnyc avatar

Golang Concurrency Patterns

Go concurrency patterns for production services: context cancellation, errgroup, worker pools, and race avoidance.

CCM score
59 of 100
skills.sh installs
429
GitHub stars
79
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers context-driven goroutine lifetimes, errgroup fan-out with sibling cancellation, bounded parallelism, worker pools, and pipeline stages
  • Includes correct and incorrect code pairs for each pattern, plus guidance on channels versus mutexes and when to use each
  • Enforces explicit goroutine shutdown conditions, sender-only channel closing, and time.NewTicker over time.After in loops
  • Guides verification with go test -race and context timeouts, and troubleshooting for deadlocks and goroutine leaks

Install

$ npx -y skills add bobmatnyc/claude-mpm-skills --skill golang-concurrency-patterns -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

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.

Core Concepts

Goroutine lifecycle

Treat goroutines as resources with a clear owner and shutdown condition.

✅ Correct: stop goroutines via context

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

Details

Repository
github.com/bobmatnyc/claude-mpm-skills
Categories
Go, Backend & APIs
First seen
Jun 3, 2026

Questions

Is golang-concurrency-patterns a good Go skill for goroutine and channel work?

It sits in the Go category on Claude Marketplaces and ranks in the top 100 there, alongside golang-code-style, golang-testing, golang-error-handling, golang-design-patterns and golang-concurrency. It sets itself apart by covering context cancellation, errgroup, worker pools, bounded parallelism and fan-in/fan-out with common race and deadlock pitfalls.

How do I install the golang-concurrency-patterns skill?

Run npx -y skills add bobmatnyc/claude-mpm-skills --skill golang-concurrency-patterns -y in your project. Once installed, the agent can write race-free, cancellation-aware Go using context, errgroup, channels and bounded concurrency patterns.

What does the golang-concurrency-patterns skill help with?

It helps when implementing concurrent pipelines, background workers, fan-out/fan-in, or fixing goroutine leaks, deadlocks and data races in Go services. It explains when to use channels versus mutexes and when to choose errgroup over WaitGroup.

Does the golang-concurrency-patterns skill need any tools or accounts?

The skill lists no required tools, and its guidance uses standard Go packages such as context, sync and errgroup. Testing advice relies on the Go race detector run with go test -race.

More from bobmatnyc/claude-mpm-skills

All 154

Similar to Golang Concurrency Patterns

More Go