GitHub - lotusirous/go-concurrency-patterns: Concurrency patterns in Go · GitHub
A Go example repository covering 18 practical concurrency patterns, from goroutines and channels to cancellation, bounded parallelism, ring buffers, and worker pools. Each pattern links to runnable Go Playground code and supporting talks or articles.
GitHub - lotusirous/go-concurrency-patterns: Concurrency patterns in Go · GitHub
Author: lotusirous | Published: Unknown | Generated: 2025-01-31 | Domain: github.com
Tags: ‘#golang’ ‘#concurrency’ ‘#goroutines’ ‘#channels’ ‘#patterns’ ‘#workerpool’
TLDR
This repository is a compact, runnable catalog of Go concurrency patterns, progressing from basic goroutines and channels through fan-in, generators, timeouts, cancellation signals, and pipeline-style concurrent search. It also includes more advanced examples for subscriptions, context propagation, bounded parallelism, ring-buffer channels, and worker pools, with links to authoritative Go talks and documentation. The main value is hands-on code paired with Go Playground demos for experimenting with each technique.
Key Takeaways
- 18 runnable examples: The repository covers goroutines, channels, generators, fan-in, sequencing,
selecttimeouts, quit signals, daisy chains, concurrent search, ping-pong, subscriptions, contexts, ring buffers, and worker pools. - Progressive concurrency search: Four “Google” examples build a concurrent search implementation incrementally, illustrating how to compose parallel services and collect results.
- Cancellation and lifecycle control: Examples include timeout handling, quit signals, and
contextuse in HTTP clients and servers—core techniques for preventing leaked goroutines and propagating cancellation. - Throughput control patterns: Bounded parallelism, ring-buffer channels, and worker pools demonstrate ways to regulate work concurrency, buffer producer/consumer mismatches, and coordinate result-channel closure.
- Curated learning material: The README links to Go’s classic concurrency talks and articles, including pipelines/cancellation, timeouts, context, and advanced concurrency patterns.
- Repository activity: At the captured state, the project has 3.1k stars, 269 forks, 29 watchers, 30 commits, and no published releases.
Images & Media
None present in article.
Referenced Links
- Concurrency is not parallelism — Rob Pike’s talk distinguishing concurrency as composition from parallel execution.
- Go Concurrency Patterns — Foundational Go concurrency-patterns presentation.
- Go Concurrency Patterns source — Supporting source code for the foundational talk.
- Advanced Go Concurrency Patterns — Advanced patterns presentation covering more sophisticated channel and goroutine coordination.
- Rethinking classical concurrency pattern — Video resource on re-evaluating traditional concurrency approaches.
- Go Concurrency Patterns: Pipelines and cancellation — Go blog article on constructing pipelines and safely cancelling work.
- Go Concurrency Patterns: Timing out, moving on — Go blog article on timeout patterns using channels and
select. - Complex Concurrency Patterns with Go — Video resource on higher-level Go concurrency designs.
- Go Concurrency Patterns: Context — Go blog introduction to request-scoped deadlines, cancellation, and metadata with
context. - How to correctly use package context — Video guidance on correct
contextpackage use. - justforfunc #9: The Context Package — Video tutorial focused on Go contexts.
- Contexts and structs — Guidance on avoiding improper storage of contexts in structs.