go-concurrency-patterns
What it does
This tool helps you understand and use advanced ways to do multiple things at the same time in a Go computer program. It teaches you how to use 'goroutines' (small tasks that run together) and 'channels' (communication lines between these tasks).
When to use it
- ✓When building Go programs that need to do multiple things concurrently.
- ✓When organizing tasks to work together efficiently (like in 'worker pools').
- ✓When trying to figure out why your program is crashing or having concurrency errors.
Skill link
https://github.com/wshobson/agents/blob/main/plugins/systems-programming/skills/go-concurrency-patterns/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“How can I make two parts of my Go program run at the same time and exchange information safely?”
5 new skills a week. 1 minute to read.
How it works
It explains the basic building blocks of concurrency in Go, like 'goroutines' and 'channels', and shows examples of how to use them for communication and synchronization.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Go Concurrency Patterns
Production patterns for Go concurrency including goroutines, channels, synchronization primitives, and context management.
When to Use This Skill
- Building concurrent Go applications
- Implementing worker pools and pipelines
- Managing goroutine lifecycles
- Using channels for communication
- Debugging race conditions
- Implementing graceful shutdown
Core Concepts
1. Go Concurrency Primitives
| Primitive | Purpose |
|---|---|
goroutine |
Lightweight concurrent execution |
channel |
Communication between goroutines |
select |
Multiplex channel operations |
sync.Mutex |
Mutual exclusion |
sync.WaitGroup |
Wait for goroutines to complete |
context.Context |
Cancellation and deadlines |
2. Go Concurrency Mantra
Don't communicate by sharing memory;
share memory by communicating.
Quick Start
package main
import (
"context"
"fmt"
"sync"
"time"
)
func main() {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
results := make(chan string, 10)
var wg sync.WaitGroup
// Spawn workers
for i := 0; i < 3; i++ {
wg.Add(1)
go worker(ctx, i, results, &wg)
}
// Close results when done
go func() {
wg.Wait()
close(results)
}()
// Collect results
for result := range results {
fmt.Println(result)
}
}
func worker(ctx context.Context, id int, results chan<- string, wg *sync.WaitGroup) {
defer wg.Done()
select {
case <-ctx.Done():
return
case results <- fmt.Sprintf("Worker %d done", id):
}
}
Detailed patterns and worked examples
Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.
Best Practices
Do's
- Use context - For cancellation and deadlines
- Close channels - From sender side only
- Use errgroup - For concurrent operations with errors
- Buffer channels - When you know the count
- Prefer channels - Over mutexes when possible
Don'ts
- Don't leak goroutines - Always have exit path
- Don't close from receiver - Causes panic
- Don't use shared memory - Unless necessary
- Don't ignore context cancellation - Check ctx.Done()
- Don't use time.Sleep for sync - Use proper primitives
FAQ
What is a 'goroutine'?
It's like a function that can run at the same time as other parts of your program, without interfering.
What are 'channels' for?
They are like pipes through which 'goroutines' can send and receive messages to each other safely.
What does 'Don't communicate by sharing memory; share memory by communicating' mean?
It's advice to avoid having multiple parts of your program access the same data at the same time (which can cause errors). Instead, use 'channels' to pass data between them.
Details
Original description by the author
Master Go concurrency with goroutines, channels, sync primitives, and context. Use when building concurrent Go applications, implementing worker pools, or debugging race conditions.
repo: wshobson/agents
Popularity
- GitHub stars
- 41k
- Ranking position
- #6798
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
screen-reader-testing
41kHas your agent test websites using screen readers to ensure they are accessible.
wcag-audit-patterns
41kHelps your agent audit websites for accessibility and fix issues according to WCAG guidelines.
multi-reviewer-patterns
41kEnables your agent to coordinate parallel code reviews, deduplicating findings and consolidating reports.
parallel-debugging
41kAllows the agent to debug complex issues with parallel investigations and root cause analysis.
Similar skills
diffs
394kLets your agent produce a real, shareable diff of edits as a viewer link or image file, instead of a hand-written summary.
coding-agent
394kHelps your agent hand a larger coding job to Codex, Claude Code, or OpenCode as a background worker, then check on its progress.
gh-issues
394kHelps your agent find GitHub issues, pick the ones to work on, and open pull requests with fixes, including follow-up on review comments.