go-concurrency-pipelines
Design, implement, test, and review bounded in-process Go concurrency using goroutines, channels, iterators, mutexes, shared collections, WaitGroup, errgroup, backpressure, ordering, cancellation, and deterministic lifecycle checks. Use when building worker pools, streaming pipelines, concurrent batches, background stages, or diagnosing races, goroutine leaks, blocked operations, synchronization ownership, and shutdown failures.
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 1.6k
- Forks
- 491
01 前言 Front Matter
- name
- go-concurrency-pipelines
- license
- MIT
- metadata
- { "tags": "go,golang,concurrency,goroutines,channels,pipelines", "version": "0.2.0", "category": "Go", "displayName": "Go Concurrency Pipelines" }
- description
- Design, implement, test, and review bounded in-process Go concurrency using goroutines, channels, iterators, mutexes, shared collections, WaitGroup, errgroup, backpressure, ordering, cancellation, and deterministic lifecycle checks. Use when building worker pools, streaming pipelines, concurrent batches, background stages, or diagnosing races, goroutine leaks, blocked operations, synchronization ownership, and shutdown failures.
- compatibility
- Codex, Claude Code, and other Agent Skills-compatible clients.
02 资源文件 8
- 参考文档agents/openai.yaml225 B
- 参考文档guidelines.md1.2 KB
- 参考文档references/concurrency-pipelines/examples.md1.9 KB
- 参考文档references/concurrency-pipelines/knowledge.md3.2 KB
- 参考文档references/concurrency-pipelines/rules.md2.8 KB
- 参考文档workflows/design-cancellable-pipeline.md974 B
- 参考文档workflows/review-goroutine-lifecycle.md805 B
- 参考文档workflows/test-concurrency-contract.md903 B
03 SKILL.md 正文
Go Concurrency Pipelines
Every goroutine needs an owner, a stop condition, and a completion path. Bound admission before optimizing throughput.
Core Workflow
- Define input, output, ordering, partial-result, and failure contracts.
- Prefer a synchronous or iterator API unless callers need channel mechanics.
- Assign ownership of goroutines, channel closure, timers, and cancellation.
- Bound concurrency, queues, retries, and memory together.
- Make every blocking send, receive, and wait cancellation-aware.
- Join all owned goroutines on success, failure, cancellation, and early exit.
- Test lifecycle behavior with barriers and deadlines rather than sleeps.
- Review shared maps, slices, locks, wait groups, and copied synchronization values.
- Run race checks and inspect leak-prone paths.
Read Next
| Task | Load |
|---|---|
| Design a pipeline | guidelines.md, workflows/design-cancellable-pipeline.md |
| Review goroutine ownership | workflows/review-goroutine-lifecycle.md |
| Test concurrency deterministically | workflows/test-concurrency-contract.md |
| Choose channels, iterators, buffers, or ordering | references/concurrency-pipelines/knowledge.md, references/concurrency-pipelines/rules.md |
| Review mutexes, WaitGroup, errgroup, or shared collections | references/concurrency-pipelines/rules.md, references/concurrency-pipelines/examples.md |
| Review patterns | references/concurrency-pipelines/examples.md |
Guardrails
- Only a sender that owns completion closes a channel.
- Do not use a buffer as a substitute for cancellation and joining.
- Do not expose internal channels when an iterator or synchronous result suffices.
- Do not assume
selectguarantees fairness. - Do not multiply a concurrency limit through hidden retries or nested fan-out.
- Do not prove timing behavior with arbitrary sleeps.
- Do not copy values containing mutexes, wait groups, conditions, or other sync state.
- Do not detach work from a request without a new bound, owner, error sink, and join policy.
Source Notes
Guidance is transformed and paraphrased from Inanc Gumus, Go by Example: Programmer's Guide to Idiomatic and Testable Programs (Manning, 2025), Chapters 6-7 and Appendix E. Examples are original.
Synchronization, context, and shared-collection guidance also incorporates transformed material from Teiva Harsanyi, 100 Go Mistakes and How to Avoid Them (Manning, 2022), Chapters 8-9.
Book: https://www.manning.com/books/go-by-example
Verify language and API behavior against https://go.dev/ref/spec, https://pkg.go.dev/context, https://pkg.go.dev/iter, and https://go.dev/doc/articles/race_detector.
04 同仓库更多 Skills
worktable-review-with-annotations
Create, inspect, reply to, update, or resolve situated Worktable annotations. Use when feedback belongs to a Doc section, block, text range, or HTML Doc, or when the user asks to address existing review feedback and coordinate a requested artifact edit.
worktable-find-and-synthesize-context
Find, assess, and synthesize context from Worktable Docs and Records. Use when the user asks what a workspace contains, wants workspace-backed research, needs current facts reconciled across artifacts, or requests a cited synthesis without changing workspace state.
worktable-create-or-update-docs
Create, edit, rename, or maintain narrative Worktable Docs. Use for plans, decisions, briefs, notes, research syntheses, and other durable prose when the user requests a new artifact or a safe update to an existing one.
worktable-create-or-manage-records
Organize repeated structured information as durable Worktable Records. Use for research datasets, inventories, directories, pipelines, trackers, and other collections whose items need identity, fields, filtering, links, validation, or individual updates.
worktable-create-or-manage-interactive-html
Create or improve durable visual and interactive artifacts in Worktable. Use for dashboards, trackers, calculators, mini apps, slide presentations, and other requests that benefit from a polished HTML Doc.
worktable-collaborate-threads
Read, answer, and hand off messages through durable Worktable threads with users or other authenticated participants. Use when the user asks to check addressed messages, reply to a participant, continue a thread, request another agent's help, wait briefly for a response, or watch for comments and messages sent to the agent.