go-concurrency
Go concurrency patterns. Routes to specific patterns.
When & Why to Use This Skill
This Claude skill serves as a comprehensive technical reference for Go concurrency patterns, providing structured guidance on goroutine management, channel communication, and synchronization primitives. It helps developers architect robust, leak-free concurrent systems by offering decision trees, safety checklists, and best practices for context propagation and resource cleanup in Golang.
Use Cases
- Designing Scalable Systems: Use the decision tree to select the most appropriate synchronization method—such as Channels for data flow or Mutexes for mutual exclusion—ensuring efficient architectural choices.
- Preventing Resource Leaks: Apply the 'Quick Check' list during the design phase to ensure every goroutine has a defined exit path and that context cancellation is correctly implemented.
- Code Review and Optimization: Identify and rectify common concurrency pitfalls, such as closing channels from the receiver side or improper WaitGroup counter placement, to enhance system stability.
- Implementing Graceful Shutdowns: Utilize standardized context-based cancellation patterns to ensure all background processes in a microservice terminate correctly upon receiving stop signals.
| name | go-concurrency |
|---|---|
| description | Go concurrency patterns. Routes to specific patterns. |
Concurrency
Route by Pattern
- Context cancellation → see context/
- Goroutine leaks → see goroutines/
- Channel patterns → see channels/
- Sync primitives → see sync/
Quick Check
- Every goroutine has exit path
- Context passed and checked
- Channels closed by sender only
- WaitGroup Add before go
Common Pitfalls
- Launching goroutines without shutdown mechanism
- Not propagating context through call chains
- Closing channels from receiver side
- Using WaitGroup counter incorrectly
Decision Tree
Need coordination? → Use context for cancellation
Need data flow? → Use channels
Need to wait? → Use sync.WaitGroup
Need mutual exclusion? → Use sync.Mutex