Table of Contents
- Month 3 — Runnable Examples
- How to run
- Index (Week 1 — goroutines, channels, select)
- Index (Week 2 — the sync toolbox & atomics)
- Index (Week 3 — concurrency patterns)
- Index (Week 4 — concurrency project: a crawler)
Month 3 — Runnable Examples¶
Single-concept, stdlib-only programs backing the Month 3 daily notes
(concurrency & parallelism). Each folder is its own package main.
How to run¶
Index (Week 1 — goroutines, channels, select)¶
| Topic | Concept | Day |
|---|---|---|
goroutines/ |
go statement, sync.WaitGroup, loop-var capture (Go 1.22) |
057 |
channels/ |
unbuffered rendezvous vs buffered, close, range |
058 |
select-timeout/ |
select, default, time.After, Ticker/Timer, labelled break |
060 |
generator/ |
generator pattern, done channels, fan-in merge |
062 |
Index (Week 2 — the sync toolbox & atomics)¶
| Topic | Concept | Day |
|---|---|---|
mutex/ |
sync.Mutex & RWMutex, critical sections, no-copy rule |
064 |
waitgroup/ |
WaitGroup fan-out, lock-free collection, errors.Join |
065 |
once-pool/ |
sync.Once lazy init, sync.Pool object reuse |
066 |
atomic/ |
sync/atomic typed values, CompareAndSwap, CAS retry loop |
067 |
Index (Week 3 — concurrency patterns)¶
| Topic | Concept | Day |
|---|---|---|
workerpool/ |
fixed N goroutines over a jobs channel; ordered vs unordered results |
071 |
fanin-fanout/ |
fan-out workers over one source, fan-in merge with a closer goroutine |
072 |
pipeline-cancel/ |
multi-stage pipeline; every stage selects on ctx.Done() to avoid leaks |
073 |
bounded-sem/ |
bounded parallelism via a buffered-channel counting semaphore | 074 |
context-cancel/ |
WithCancel/WithTimeout, deadlines, parent→child propagation |
075 |
errgroupand token-bucket rate limiting (Day 076) needgolang.org/x/..., outside the stdlib, so they live as snippets in the day notes rather than as runnable examples here.
Index (Week 4 — concurrency project: a crawler)¶
| Topic | Concept | Day |
|---|---|---|
crawler/ |
concurrent crawler: bounded worker pool + single-owner dedup, no mutex | 078-079 |
graceful-shutdown/ |
signal.NotifyContext + context cancellation, drain & WaitGroup |
080 |
rate-ticker/ |
stdlib rate limiting: time.Ticker pacing vs. token-bucket channel |
081 |
pprof-demo/ |
runtime/pprof CPU + heap profiles of parallel work; go tool pprof |
083 |
Tip: run everything with the race detector to surface data races early:
go run -race ./examples/month-03/goroutines