Context Handling in fp-go
IBM/fp-go
Covers handling Go's context.Context idiomatically in fp-go code: reading and scoping context through operators, timeouts, cancellation and converting ctx-first functions.
Idiomatic Go concurrency - sync primitives, channel semantics, the select statement, and the standard channel patterns (cancellation/done-channel, fan-out/fan-in, pipeline, or-done, context…
$ npx skills add inference-gateway/inference-gateway --skill go-concurrency -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install inference-gateway/inference-gateway go-concurrency --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/inference-gateway/inference-gateway.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/go-concurrency .claude/skills/go-concurrency && rm -rf skills-srcUse ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.
Claude Code skills documentation · loads skills from .claude/skills/
Install the "go-concurrency" agent skill from https://github.com/inference-gateway/inference-gateway/tree/main/.agents/skills/go-concurrency into .claude/skills/go-concurrency/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "go-concurrency", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/inference-gateway/inference-gateway/tree/main/.agents/skills/go-concurrencyType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add inference-gateway/inference-gateway --skill go-concurrency -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install inference-gateway/inference-gateway go-concurrency --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/inference-gateway/inference-gateway.git skills-src && mkdir -p .agents/skills && cp -r skills-src/.agents/skills/go-concurrency .agents/skills/go-concurrency && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "go-concurrency" agent skill from https://github.com/inference-gateway/inference-gateway/tree/main/.agents/skills/go-concurrency into .agents/skills/go-concurrency/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "go-concurrency", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add inference-gateway/inference-gateway --skill go-concurrency -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install inference-gateway/inference-gateway go-concurrency --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/inference-gateway/inference-gateway.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/.agents/skills/go-concurrency .cursor/skills/go-concurrency && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "go-concurrency" agent skill from https://github.com/inference-gateway/inference-gateway/tree/main/.agents/skills/go-concurrency into .cursor/skills/go-concurrency/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "go-concurrency", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/inference-gateway/inference-gateway.git --path .agents/skills/go-concurrency--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add inference-gateway/inference-gateway --skill go-concurrency -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install inference-gateway/inference-gateway go-concurrency --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/inference-gateway/inference-gateway.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/.agents/skills/go-concurrency .gemini/skills/go-concurrency && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "go-concurrency" agent skill from https://github.com/inference-gateway/inference-gateway/tree/main/.agents/skills/go-concurrency into .gemini/skills/go-concurrency/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "go-concurrency", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install inference-gateway/inference-gateway go-concurrencyInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add inference-gateway/inference-gateway --skill go-concurrency -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/inference-gateway/inference-gateway.git skills-src && mkdir -p .github/skills && cp -r skills-src/.agents/skills/go-concurrency .github/skills/go-concurrency && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "go-concurrency" agent skill from https://github.com/inference-gateway/inference-gateway/tree/main/.agents/skills/go-concurrency into .github/skills/go-concurrency/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "go-concurrency", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add inference-gateway/inference-gateway --skill go-concurrency -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install inference-gateway/inference-gateway go-concurrency --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/inference-gateway/inference-gateway.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/.agents/skills/go-concurrency .opencode/skills/go-concurrency && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "go-concurrency" agent skill from https://github.com/inference-gateway/inference-gateway/tree/main/.agents/skills/go-concurrency into .opencode/skills/go-concurrency/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "go-concurrency", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
go-concurrencyIdiomatic Go concurrency - sync primitives, channel semantics, the select statement, and the standard channel patterns (cancellation/done-channel, fan-out/fan-in, pipeline, or-done, context…
Go Concurrency is an agent skill from inference-gateway/inference-gateway. Idiomatic Go concurrency - sync primitives, channel semantics, the select statement, and the standard channel patterns (cancellation/done-channel, fan-out/fan-in, pipeline, or-done, context, worker-pool). Use when writing or reviewing Go that spawns goroutines, shares state, or coordinates over channels, even if the user never says "concurrency" - e.g. data races, deadlocks, goroutine leaks, sync/context/select usage, or "make this parallel". Distilled from luk4z7/go-concurrency-guide.
Its SKILL.md is about 2.3k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.
It sits in Development, covering Async programming. It works with DeepSeek, Model Context Protocol, OpenAI and Kubernetes. The repository describes itself as: An open-source, cloud-native, high-performance gateway unifying multiple LLM providers, from local solutions like Ollama to major cloud providers such as OpenAI, Groq, Cohere… The licence is Apache-2.0.
Read from SKILL.md and the folder at commit 49d1f12. It shows what the files ask for, not the result of running them.
Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.
From allowed-tools in the SKILL.md frontmatter.
Shell commands in SKILL.md call:
goFrom the folder's file list and the shell code blocks in SKILL.md.
Links to these hosts (documentation or services it may open):
github.comFrom URLs in SKILL.md, links to its own repository left out.
Names no API keys, tokens, secrets or passwords.
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
Go Concurrency loads about 2.3k tokens when it runs. Until then it costs about 126 tokens; SKILL.md has 786 words of instructions outside code blocks.
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
The automated check found no risky patterns in SKILL.md.
Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.
The full file from inference-gateway/inference-gateway at commit 49d1f12, republished under its Apache-2.0 licence (© inference-gateway). 786 words, ~2,314 tokens.
.claude/skills/go-concurrency/SKILL.md (or your agent's skills folder).A quick-reference for writing and reviewing concurrent Go. Reach for the table
that fits the problem, copy the nearest pattern, then check it against the
gotchas. Verify everything with go test -race.
Don't communicate by sharing memory; share memory by communicating. Use channels to pass ownership of data, distribute work, and signal. Use a mutex for in-place shared state (caches, counters, registries).
| Need | Use |
|---|---|
| Hand off / stream values between goroutines | chan |
| Protect shared state in place | sync.Mutex / sync.RWMutex (read-heavy) |
| Wait for N goroutines to finish | sync.WaitGroup |
| Run exactly once (lazy init) | sync.Once |
| Reuse expensive allocations, cut GC pressure | sync.Pool |
| Wake goroutines on a condition | sync.Cond (rare; a channel is usually clearer) |
| Lock-free counters / flags | sync/atomic |
| Cancellation, deadlines, request-scoped values | context.Context |
Always defer mu.Unlock() right after mu.Lock() so a panic can't leave the
lock held.
Behaviour is defined by the operation × the channel's state. Memorize this:
| Operation | nil channel | open channel | closed channel |
|---|---|---|---|
receive v := <-c | blocks forever | a value (or blocks if empty) | zero value, ok==false (drains buffer first) |
send c <- v | blocks forever | sends (or blocks if full) | panic |
close(c) | panic | closes it | panic |
make(chan T)): send and receive rendezvous - each blocks
until the other is ready. This is the synchronization.make(chan T, n)): send blocks only when full, receive only
when empty. A buffer decouples timing; it does not remove backpressure.closes it, then hands consumers a receive-only <-chan T. This makes the
panics above structurally impossible. Receivers never close.range c reads until the channel is closed; v, ok := <-c detects closure.select idiomsselect blocks until one case is ready; if several are ready it picks one
pseudo-randomly (so no case can starve another). nil channels are never
ready - set a channel to nil to disable its case.
// timeout - but time.After leaks a timer until it fires; in a hot loop use a
// context or a reused time.Timer instead.
select {
case v := <-c:
use(v)
case <-time.After(time.Second):
return errTimeout
}
// non-blocking poll
select {
case v := <-c:
use(v)
default: // nothing ready, carry on
}
// cancellation - prefer sending under a done/ctx guard so you never block forever
select {
case out <- v:
case <-done:
return
}go test -race / go run -race.done/ctx signal or a
channel that will close. Leaks accumulate silently.nil channel, or
an unbuffered send with no receiver. fatal error: all goroutines are asleep.for _, v := range xs { go f(v) }
shared one v; pass it as an argument. Go 1.22+ gives each iteration its own
copy. Know which Go you target.Short, copy-ready skeletons. They use any (= interface{}) and assume Go 1.22+
loop semantics.
Done-channel cancellation - pass a read-only done; close it once to stop
all listeners. Send results under the done guard so a cancelled consumer
can't wedge the producer.
func worker(done <-chan struct{}, in <-chan string) <-chan string {
out := make(chan string)
go func() {
defer close(out)
for s := range in {
select {
case out <- transform(s):
case <-done: // caller cancelled → exit, no leak
return
}
}
}()
return out
}
done := make(chan struct{})
defer close(done) // every return path cancels the workerFan-out / fan-in - many workers read one input channel (distribute load), one channel merges their results. No value is processed twice.
func fanIn(done <-chan struct{}, cs ...<-chan int) <-chan int {
out := make(chan int)
var wg sync.WaitGroup
wg.Add(len(cs))
for _, c := range cs {
go func(c <-chan int) {
defer wg.Done()
for v := range c {
select {
case out <- v:
case <-done:
return
}
}
}(c)
}
go func() { wg.Wait(); close(out) }() // close once every worker drains
return out
}Pipeline - compose stages, each a goroutine that reads one channel and
returns the next. Every stage closes the channel it owns, so closure propagates
downstream and range terminates cleanly.
func sq(in <-chan int) <-chan int {
out := make(chan int)
go func() {
defer close(out)
for n := range in {
out <- n * n
}
}()
return out
}
for n := range sq(sq(gen(2, 3))) { // 16, 81
fmt.Println(n)
}Or-done - range over a channel without leaking when you might quit early. Wrap the channel; the loop body stays clean.
func orDone(done, c <-chan any) <-chan any {
out := make(chan any)
go func() {
defer close(out)
for {
select {
case <-done:
return
case v, ok := <-c:
if !ok {
return
}
select {
case out <- v:
case <-done:
}
}
}
}()
return out
}
for v := range orDone(done, stream) { // safe; exits on done or closure
use(v)
}Context - the standard cancellation/deadline carrier. Take ctx as the
first argument, always defer cancel(), and honor ctx.Done() in your loops.
ctx, cancel := context.WithTimeout(ctx, 2*time.Second)
defer cancel() // releases resources even on early return
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
resp, err := http.DefaultClient.Do(req) // aborts on cancel/timeout
select {
case out <- v:
case <-ctx.Done():
return ctx.Err() // context.Canceled or DeadlineExceeded
}Queuing / semaphore - a buffered channel bounds how many goroutines run at once. Acquire before launching, release on exit.
sem := make(chan struct{}, runtime.NumCPU()) // N concurrent slots
var wg sync.WaitGroup
for _, job := range jobs {
sem <- struct{}{} // blocks while N are in flight
wg.Add(1)
go func(job Job) {
defer wg.Done()
defer func() { <-sem }() // free the slot
process(job)
}(job)
}
wg.Wait()Lower-frequency patterns from the source, when you need them: or-channel (combine many done signals into one), tee (duplicate one stream into two), bridge (flatten a channel-of-channels), heartbeat (periodic liveness signal for monitoring), replicated requests (fan a request to N handlers, take the first reply, cancel the rest).
Go multiplexes goroutines onto OS threads with an M:N work-stealing
scheduler: G = goroutine, M = OS thread, P = processor (a run
context). GOMAXPROCS (default runtime.NumCPU()) caps how many Ps run Go code
at once; an idle P steals goroutines from a busy P's queue. Goroutines are cheap
-race.Distilled from luk4z7/go-concurrency-guide, which draws on "Concurrency in Go" (Katherine Cox-Buday) and "The Go Programming Language".
© inference-gateway, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
Just SKILL.md in .agents/skills/go-concurrency of inference-gateway/inference-gateway.
Open the folder on GitHubat commit 49d1f12
Go Concurrency next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| Go Concurrency this skillinference-gateway/inference-gateway | 214 | — | ~2.3k | Automated safety check: Pass | Apache-2.0 | |
| Context Handling in fp-goIBM/fp-go | 2k | — | ~4.2k | Automated safety check: Pass | Apache-2.0 | |
| NGINX Ingress Controller Structurenginx/kubernetes-ingress | 5.1k | — | ~3.8k | Automated safety check: Pass | Apache-2.0 | |
| Dotnet Debuggingnovotnyllc/dotnet-artisan | 233 | — | ~2.1k | Automated safety check: Pass | MIT | |
| Mesh APImr-tbot/mesh-api | 180 | — | ~1.8k | Automated safety check: Pass | GPL-3.0 | |
| Juror ReviewJuror-AI/juror | 120 | — | ~576 | Automated safety check: Pass | MIT |
IBM/fp-go
Covers handling Go's context.Context idiomatically in fp-go code: reading and scoping context through operators, timeouts, cancellation and converting ctx-first functions.
nginx/kubernetes-ingress
Maps the NGINX Kubernetes Ingress Controller codebase: repository layout, architectural layers, layer-crossing rules and which files are generated.
novotnyllc/dotnet-artisan
Debugs Windows and Linux/macOS applications (native, .NET/CLR, mixed-mode) with WinDbg MCP (crash dumps, !analyze, !syncblk, !dlk, !runaway, !dumpheap, !gcroot, BSOD), dotnet-dump, lldb with SOS…
mr-tbot/mesh-api
Interact with a Meshtastic LoRa mesh network through MESH-API — list nodes, read messages, send texts, and check connection status.
Juror-AI/juror
Inspect Juror Cloud PR findings and, only after an explicit confirmation, start or rerun a hosted Juror review.
kubernetes-sigs/cloud-provider-azure
Diagnose and unblock failed Dependabot pull requests in cloud-provider-azure by closing Kubernetes minor-version dependency bumps, classifying CI failures, syncing Go modules, retesting quota-flaked…
inference-gateway/inference-gateway
Idiomatic Go - package and interface design, error wrapping, table-driven tests, generics, the modern standard library (slices/maps/cmp/errors.Join), current syntax, and logging discipline.
inference-gateway/inference-gateway
Review a Go design spec before implementation begins - dispatch a subagent that checks a design doc for completeness, consistency, and idiomatic Go (simplicity, small consumer-defined interfaces…
Categories
Idiomatic Go concurrency - sync primitives, channel semantics, the select statement, and the standard channel patterns (cancellation/done-channel, fan-out/fan-in, pipeline, or-done, context…. Go Concurrency is an agent skill from inference-gateway/inference-gateway. Idiomatic Go concurrency - sync primitives, channel semantics, the select statement, and the standard channel patterns (cancellation/done-channel, fan-out/fan-in, pipeline, or-done, context, worker-pool).
Go Concurrency fits situations like: reviewing Go that spawns goroutines; coordinates over channels; even if the user never says concurrency - e.g.
Run `npx skills add inference-gateway/inference-gateway --skill go-concurrency -a claude-code`. Or copy the skill folder (.agents/skills/go-concurrency in inference-gateway/inference-gateway) into .claude/skills/go-concurrency in your project. Claude Code loads it when a task matches its description.
Run `npx skills add inference-gateway/inference-gateway --skill go-concurrency -a codex`. Or copy the skill folder (.agents/skills/go-concurrency in inference-gateway/inference-gateway) into .agents/skills/go-concurrency in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add inference-gateway/inference-gateway --skill go-concurrency -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/go-concurrency, .gemini/skills/go-concurrency, .github/skills/go-concurrency and .opencode/skills/go-concurrency in your project.
Going by SKILL.md and its folder, Go Concurrency needs the command-line tools its instructions call (go).
SKILL.md names 1 domain. As links in the text: github.com. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.
Go Concurrency is published under the Apache-2.0 licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.
About 2.3k tokens (SKILL.md is roughly 9.3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.
Skills that share tags, products or a category with Go Concurrency: Context Handling in fp-go (IBM/fp-go, 2k stars), NGINX Ingress Controller Structure (nginx/kubernetes-ingress, 5.1k stars), Dotnet Debugging (novotnyllc/dotnet-artisan, 233 stars) and Mesh API (mr-tbot/mesh-api, 180 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
inference-gateway (a GitHub organization) maintains it in inference-gateway/inference-gateway, which has 214 GitHub stars. The repository holds 3 skills in this directory. The repository was last updated on October 8, 2026.
Source: inference-gateway/inference-gateway on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.