go-concurrency-patterns
Skill0 starsChanged 39 days agoMITView on GitHub
Use when designing Go concurrent code — goroutine lifetimes, channel sizing, worker pools, parallelization, or diagnosing goroutine leaks and data races; covers semaphore via buffered channel, leaky buffer, fan-out, channel-of-channels for RPC
11 other projects use a version of this.
Adopted by
Most recently taken up by
- ControllableModel/SWE-Skills-Benchtheir own version, first seen Nov 8, 2026
- chenwei791129/agent-skillstheir own version, first seen Oct 19, 2026
- xfstudio/skillstheir own version, first seen Oct 13, 2026
- Samueladewole/claude-skillstheir own version, first seen Oct 13, 2026
- carrot-hu23/dst-admin-gotheir own version, first seen Oct 8, 2026
- Ghosteken/agent-harnesstheir own version, first seen Oct 1, 2026
Other versions11 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 11
- carrot-hu23/dst-admin-go★ 920same name
- xfstudio/skills★ 9same name
- ControllableModel/SWE-Skills-Bench★ 8same name
- ai4brands-design/claude-skills★ 2same name
- CodeWithBehnam/cc-docs★ 2same name
- Ghosteken/agent-harness★ 2same name
- NorkzYT/claude-code-autopilot★ 2same name
- caijiatao/skills★ 1same name
- codecharmhq/claude-code-skills★ 1same name
- chenwei791129/agent-skills★ 0same name
1 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository66 other files it gives its agents.
- AGENTS.mdAGENTS.md
- postgres-locking-joinsSkill
- ai-bug-patternsSkill
- compressed-ndjson-boundariesSkill
- http-resume-integritySkill
- linux-io-latency-triageSkill
- macos-disk-space-recoverySkill
- minimal-sufficient-evidenceSkill
- modularize-large-filesSkill
- patch-reproducer-validitySkill
- prompt-cache-boundariesSkill
- proton-drive-selective-backupSkill
- transactional-outbox-deliverySkill
- conventional-commitsSkill
- git-advanced-mergingSkill
- git-bisect-forensicsSkill
- git-data-recoverySkill
- git-hooksSkill
- git-rerereSkill
- git-reset-mechanicsSkill
- git-revisions-syntaxSkill
- git-rewriting-historySkill
- git-submodulesSkill
- git-worktreesSkill
- github-ssh-keysSkill
- npm-publish-ci-pitfallsSkill
- sapling-stacked-pr-workflowSkill
- go-data-idiomsSkill
- go-error-handlingSkill
- go-interfaces-embeddingSkill
- go-pprof-profilingSkill
- marketing-funnel-diagnosisSkill
- marketing-geo-experimentsSkill
- marketing-incrementalitySkill
- marketing-positioning-testsSkill
- python-descriptors-mroSkill
- python-logging-cookbookSkill
- python-scaling-regression-testsSkill
- python-unicode-gotchasSkill
- rust-compile-time-invariantsSkill
- rust-deterministic-concurrency-testsSkill
- rust-error-identity-boundariesSkill
- rust-regex-search-contractsSkill
- rust-runtime-bug-classesSkill
- rust-tokio-actor-deliverySkill
- rust-tokio-cancellation-safetySkill
- sales-discovery-qualificationSkill
- sales-mutual-action-plansSkill
- sales-pipeline-forecast-calibrationSkill
- sales-value-negotiationSkill
- ai-triage-evaluationSkill
- container-image-patchingSkill
- dependency-artifact-integritySkill
- dnssec-sentinel-diagnosticsSkill
- iam-policy-change-replaySkill
- rbvm-applicabilitySkill
- rbvm-asset-evidenceSkill
- rbvm-guarded-remediationSkill
- rbvm-priority-decisionsSkill
- rbvm-risk-exceptionsSkill
- The first 60 shown.
The file
Files
Go Concurrency Patterns
Ownership transfers on send: one goroutine owns a value at a time. Unbuffered = sync point; buffered = bounded decoupling.
Channel blocking
| Op | Unbuffered | Buffered (N) |
| send | blocks until recv ready | blocks when full |
| recv | blocks until sender ready | blocks when empty |
| send on closed | panics | panics |
| recv on closed | zero, ok=false | drain, zero, ok=false |
Semaphore via buffered channel
var sem = make(chan struct{}, MaxOutstanding)
func handle(r *Request) {
sem <- struct{}{}
defer func() { <-sem }()
process(r)
}Replaces mutex+counter. struct{} is zero-byte.
Non-blocking select (leaky buffer)
select {
case b = <-freeList: // try pool
default:
b = new(Buffer) // allocate fallback
}
...
select {
case freeList <- b: // try return
default: // drop; GC reclaims
}default: makes select non-blocking.
Channel-of-channels for replies
type Request struct {
args []int
reply chan int
}
queue <- &Request{args, make(chan int)}
ans := <-req.replyEach request carries its own reply channel — no correlation IDs.
Fan-out across cores
n := runtime.GOMAXPROCS(0)
c := make(chan int, n) // buffered for drain
for i := 0; i < n; i++ { go worker(i, c) }
for i := 0; i < n; i++ { <-c } // joinBuffer size = worker count so the last worker never blocks.
Pitfalls
- Loop-variable capture (Go <1.22):
for req := range q { go f(req) }— all goroutines see the finalreq. Pass as arg:go func(r *Req){ f(r) }(req), or upgrade to 1.22+. - Goroutine leak:
go func(){ c <- 1 }()with no receiver blocks forever; the goroutine outlives its caller. Size buffers correctly or guarantee a receiver before sending. - Closing from the receiver side: sending on a closed channel panics. Only the sole sender may close; with multiple senders use a separate
donechannel orsync.Once. - Unbuffered self-deadlock: sending and receiving on the same unbuffered channel in one goroutine deadlocks instantly.
- Select starvation:
selectchooses randomly among ready cases. Adefault:branch disables blocking entirely — don't include one when you actually want to wait.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

