alex123098/my-dotfiles/go-concurrency
Claude Code and agent skill by alex123098/my-dotfiles
Trust tier 3
- community
Source check pending
Checking that the SKILL.md file is still in the repository.
Go concurrency patterns — goroutines, channels, sync primitives, errgroup, pipelines. Use when writing or reviewing concurrent Go code involving goroutines, channels, select, locks, worker pools, or fan-out/fan-in patterns.
Install
npx vskill@latest install alex123098/my-dotfiles/go-concurrencySKILL.md
Procedure
- Goroutine Discipline: Every goroutine must have a clear exit path — without a shutdown mechanism, they leak. Before spawning: (1) How will it exit? (2) Can I signal it to stop? (3) How do I wait for it? (4) Who owns the channels? (5) Could this be synchronous instead? Use context cancellation or done channels for signaling. Track leaks with
go.uber.org/goleak.VerifyTestMain(m). - Channels: Owner = sender creates and closes. Only the sender closes a channel. Specify direction (
chan<-send-only,<-chanreceive-only) — compiler prevents misuse. Default to unbuffered channels — larger buffers mask backpressure. Always includectx.Done()in select to allow cancellation. Avoid repeatedtime.Afterin hot loops — allocate once and reuse. Send values (copies), not pointers — sending pointers creates invisible shared memory. - Channel vs Mutex vs Atomic: Channels = passing data between goroutines, coordinating lifecycle. Mutex/RWMutex = protecting shared struct fields.
sync/atomic= simple counters, flags (prefer typed atomics:atomic.Int64,atomic.Boolsince Go 1.19).sync.Map= read-heavy concurrent map access (otherwise use RWMutex+map). - WaitGroup vs errgroup:
sync.WaitGroup= fire-and-forget, no errors.errgroup.Group= collect first error.errgroup.WithContext= cancel siblings on first error.errgroup.SetLimit(n)= built-in worker pool with bounded concurrency. Go 1.25+:wg.Go(func(){...})for simple fire-and-wait. - Common Sync Primitives:
sync.Once/OnceFunc/OnceValue= one-time init.singleflight.Group= deduplicate concurrent calls (cache stampede prevention).sync.Pool= reuse temporary objects (alwaysReset()beforePut()). Keep mutex critical sections short — never hold across I/O. Never upgrade RLock to Lock (deadlock). - Pipelines & Worker Pools: Fan-out multiple goroutines to process data, fan-in a results channel. Use errgroup with SetLimit for bounded worker pools. Use Go 1.23+ iterators for lazy evaluation. Always check context cancellation between pipeline stages. For graceful shutdown patterns, signal completion via context or done channel.
Pitfalls
- Fire-and-forget goroutines without stop mechanism — they leak until process restart.
- Calling
wg.Add()inside the goroutine instead of beforego func()—Wait()may return early. - Closing a channel from the receiver panics if the sender writes after close.
- Missing
ctx.Done()in select — goroutine won't respond to cancellation. - Unbounded goroutine spawning — use
errgroup.SetLimit(n)or a semaphore. - Sharing pointers via channels — defeats channel's purpose of communicating ownership.
- Mutex held across I/O operations — blocks other goroutines for no reason.
- Not running
-racein CI — most races don't crash in dev but cause data corruption in production.
Verification
go test -race ./...passes cleanly — no race conditions.goleak.VerifyTestMain(m)passes — no goroutine leaks.- Every
go func()has a correspondingsync.WaitGrouporerrgrouptracking. - No
time.Afterin hot loops — usestime.NewTimer+Reset. - All
selectstatements includectx.Done().
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingpi/.pi/agent/skills/go-concurrency/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/alex123098/my-dotfiles/go-concurrency)