go-concurrency
Goroutine lifetime, context cancellation, channel direction and the mistakes that make Go concurrency leak or race.
Skill by UnicoLab
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/unicolab-go-concurrency
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/go-concurrency
What's inside
- Skill name
go-concurrency- Description
- Goroutine lifetime, context cancellation, channel direction and the mistakes that make Go concurrency leak or race.
- License
- MIT
- Instructions
- 52 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# Go concurrency without leaks
**Every goroutine needs an owner who knows how it stops.** If you cannot point
at the line that ends it, it is a leak.
```go
func (s *Server) Start(ctx context.Context) error {
g, ctx := errgroup.WithContext(ctx) // or a WaitGroup + explicit done chan
g.Go(func() error {
for {
select {
case <-ctx.Done():
return ctx.Err() // the exit the owner can rely on
case job := <-s.jobs:
if err := s.handle(ctx, job); err != nil {
return err
}
}
}
})
return g.Wait()
}
```
## The mistakes, in the order they actually happen
1. **A goroutine writing to a channel nobody reads.** The sender blocks forever
and the goroutine never returns. Give the channel a buffer sized to the known
number of sends, or select on `ctx.Done()` in the send.
2. **`wg.Add` inside the goroutine.** It races with `wg.Wait()`. Add before
`go`, and `defer wg.Done()` as the goroutine's first line.
3. **Capturing the loop variable** (Go < 1.22): pass it as an argument.
4. **A `context.Context` stored in a struct.** Pass it as the first parameter.
The one exception the standard library makes is a request-scoped struct that
is itself short-lived.
5. **Ignoring the context in a blocking call.** `time.Sleep(d)` cannot be
cancelled; `select { case <-time.After(d): case <-ctx.Done(): }` can.
6. **A mutex copied by value.** Once a struct has a `sync.Mutex`, it must be
passed by pointer — `go vet` catches this; run it.
7. **`defer mu.Unlock()` missing on one return path.** Put the defer on the line
after the Lock, always.
8. **Closing a channel from the receiver side.** Only the sender closes, and
only once. A second close panics.
9. **Assuming `-race` proves safety.** It only reports races it observed; a
single-goroutine test observes none. Exercise the concurrent path.
## Verifying
`go test ./... -race -count=1`. `-count=1` defeats the test cache; without it a
"fix" can pass on a cached result.From UnicoLab/smlcode, MIT.
More from UnicoLab/smlcode
- 0.584score
api-versioning
UnicoLab
HTTP API design and evolution — resource shapes, status codes, pagination, and how to change an API without breaking its clients.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
conventional-commits
UnicoLab
Commit and PR messages that survive a `git log` six months later — Conventional Commits, imperative subjects, and what belongs in the body.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
dockerfile-hygiene
UnicoLab
Dockerfiles that build fast, stay small and do not run as root — layer ordering, multi-stage builds and the cache rules behind them.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
go-table-tests
UnicoLab
Write Go tests the standard way — table-driven subtests, t.Helper, t.Cleanup, and what to assert instead of reflect.DeepEqual.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
hve-rpi
UnicoLab
Hypervelocity Engineering RPI loop (Research, Challenge, Plan, Implement, Review) with FAR rubric and uncertainty tracking.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
hve-security-rai
UnicoLab
STRIDE threat modeling, OWASP/MCSB security planning, OpenSSF/SLSA supply chain hygiene, and NIST AI RMF Responsible AI.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
openshift-manifests
UnicoLab
OpenShift deployment specs that pass the restricted SCC on the first apply — kustomize base/overlays, probes, limits, secrets done safely, and how to explain…
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
pytest-fixtures
UnicoLab
pytest fixtures, parametrize, tmp_path and monkeypatch — the idioms that replace setUp boilerplate and shared mutable state.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
python-typing
UnicoLab
Type hints that actually help — Optional, generics, Protocol, and the mutable-default and import-cycle traps around them.
SkillAFreshness: A★ 1Claude Code +9 - 0.581score
hve-ux-design
UnicoLab
Design Thinking (DFV) and UX architecture for user flows, component hierarchy, and interactive state matrices.
SkillAFreshness: A★ 1Claude Code +9 - 0.581score
honest-verification
UnicoLab
Prove the objective was met, not merely that nothing is red — a suite that was already green is not evidence.
SkillAFreshness: A★ 1Claude Code +9 - 0.581score
hve-requirements
UnicoLab
BRD 3-phase discovery, PRD 7-phase specification, Epic/Story/Task decomposition, and Socratic ADR coaching.
SkillAFreshness: A★ 1Claude Code +9
Signals
- Stars
- 1
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Aug 23, 2026 (2 months ago)
- Last release
- Oct 20, 2026 (9 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/UnicoLab/smlcode
- Website
- unicolab.github.io/smlcode/
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from UnicoLab
- 0.584score
api-versioning
UnicoLab
HTTP API design and evolution — resource shapes, status codes, pagination, and how to change an API without breaking its clients.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
hve-rpi
UnicoLab
Hypervelocity Engineering RPI loop (Research, Challenge, Plan, Implement, Review) with FAR rubric and uncertainty tracking.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
go-table-tests
UnicoLab
Write Go tests the standard way — table-driven subtests, t.Helper, t.Cleanup, and what to assert instead of reflect.DeepEqual.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
conventional-commits
UnicoLab
Commit and PR messages that survive a `git log` six months later — Conventional Commits, imperative subjects, and what belongs in the body.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
dockerfile-hygiene
UnicoLab
Dockerfiles that build fast, stay small and do not run as root — layer ordering, multi-stage builds and the cache rules behind them.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
hve-security-rai
UnicoLab
STRIDE threat modeling, OWASP/MCSB security planning, OpenSSF/SLSA supply chain hygiene, and NIST AI RMF Responsible AI.
SkillAFreshness: A★ 1Claude Code +9
Cite this page
go-concurrency skill. Agent Mart. https://agentmart.dev/skills/unicolab-go-concurrency (last updated 2026-10-24)