Go Concurrency

Go concurrency patterns. Routes to specific patterns. Use when this capability is needed.

tomevault-io Updated

File contents

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

  1. Launching goroutines without shutdown mechanism
  2. Not propagating context through call chains
  3. Closing channels from receiver side
  4. 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

References


Converted and distributed by TomeVault — claim your Tome and manage your conversions.

tomevault-io/skills-registry/tree/main/jamesprial--claudefiles--concurrency commit 8d4cdc4870

Frequently asked questions

npx skillmds@latest add tomevault-io/go-concurrency-3