From fuse-go
Use when: writing or reviewing Go concurrency — goroutines, channels, golang.org/x/sync/errgroup, context propagation and cancellation, sync.WaitGroup vs channels, the -race detector, or diagnosing goroutine leaks (incl. the 1.26 goroutineleak profile). Do NOT use for: sequential error handling / slog / generics / interface style (use go-core-idioms), non-Go languages, framework-specific code.
How this skill is triggered — by the user, by Claude, or both
Slash command
/fuse-go:go-concurrencyThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Goroutines, channels, `context`, and `errgroup` for Go 1.26 — plus the number-one
Goroutines, channels, context, and errgroup for Go 1.26 — plus the number-one
documented pitfall: leaking goroutines on an unbuffered channel + early return.
Before ANY implementation, use TeamCreate to spawn 3 agents:
golang.org/x/sync/errgroup signaturesAfter implementation, run fuse-ai-pilot:sniper for validation, and run tests
with go test -race ./....
| Feature | Description |
|---|---|
| Goroutines & channels | Lightweight concurrency + typed communication |
| errgroup | Parallelism + error aggregation + context cancellation |
| context | First param, propagated strictly, carries cancellation/deadline |
| WaitGroup vs channels | Counting-only vs result/error passing |
| Race detector | -race in tests/CI to catch data races |
| Leak profile (1.26) | GOEXPERIMENT=goroutineleakprofile / /debug/pprof/goroutineleak |
context.Context is the first parameter - named ctx, never stored in a structerrgroup for fan-out with errors - it handles wait + first error + cancel-race - a passing test without -race proves nothing about racesinternal/
├── fetch/
│ ├── fetch.go # errgroup.WithContext fan-out, bounded by SetLimit
│ └── worker.go # worker pool: fixed goroutines drain a jobs channel
└── pipeline/
└── stage.go # ctx-cancellable stages, buffered hand-off channels
→ See errgroup-patterns.md for full example
| Topic | Reference | When to Consult |
|---|---|---|
| Goroutines & channels | goroutines-channels.md | Buffered vs not, select, WaitGroup vs channels |
| errgroup | errgroup.md | Fan-out, error aggregation, SetLimit, TryGo |
| context | context-propagation.md | Cancellation, deadlines, propagation rules |
| Goroutine leaks | goroutine-leaks.md | The #1 pitfall + the 1.26 leak profile |
| Template | When to Use |
|---|---|
| errgroup-patterns.md | Bounded parallel work with error handling |
| worker-pool.md | Fixed workers draining a job queue |
g, ctx := errgroup.WithContext(ctx)
g.SetLimit(8) // bound concurrency
for _, u := range urls {
g.Go(func() error { return fetch(ctx, u) })
}
if err := g.Wait(); err != nil { // first non-nil error; cancels ctx
return err
}
→ See errgroup.md
ch := make(chan result, len(items)) // buffered → early return can't strand senders
→ See goroutine-leaks.md
ctx first and thread it through every blocking callerrgroup before hand-rolling WaitGroup + error channelsgo test -race; try GOEXPERIMENT=goroutineleakprofile in CI (1.26)context.Context in a struct fieldsync.WaitGroup when goroutines return errors (use errgroup)-race flagnpx claudepluginhub fusengine/agents --plugin fuse-goGuides completion of development work by verifying tests, detecting environment, and presenting structured options for merge, PR, or cleanup.
Guides creation and editing of skills using test-driven development with pressure scenarios and subagents to verify agent compliance.
Dispatches multiple subagents concurrently for independent tasks without shared state. Use when facing 2+ unrelated failures or subsystems that can be investigated in parallel.