Learn to write concurrent Go programs safely using goroutines, channels, select, the sync package and context. You will coordinate parallel work, cancel and time-out tasks, build worker pools, and prove your code is race-free with Go''s built-in race detector.
Watch the free preview
Goroutines — launching concurrent work — free to watch, no account needed.
What you'll learn
- Write concurrent Go programs safely using goroutines and channels
- Coordinate goroutines with unbuffered and buffered channels, select and channel closing
- Synchronise shared state with the sync package (WaitGroup and Mutex)
- Cancel and time-out concurrent work using the context package
- Build worker pools and prove code is race-free with the Go race detector
Syllabus
Goroutines and the Basics of Concurrency
Goroutines — launching concurrent workFree preview
Unbuffered channels — communicating between goroutines
Channels in Depth
Buffered channels, closing and ranging
select — multiplexing multiple channels
Synchronisation with sync and context
The sync package — WaitGroup and Mutex
context for cancellation and timeouts
Patterns and Safety
Worker pools and pipelines
Race detection and common concurrency pitfalls
Lab — 10 Exercises & Solutions
Exercises 1–5
Exercises 6–10