Goroutines, channels and select: your first concurrent Go
12 steps · about 4 h 3 min · Intermediate
- Concurrency is not parallelism (article, The Go Blog, 8 min)
It separates concurrency from parallelism first, so the later syntax makes sense.
- A Tour of Go (interactive, go.dev, 30 min)
Its concurrency module lets you run goroutines, channels, buffered channels, range and close, and select in the browser.
- Go by Example: Channels (tutorial, Go by Example, 8 min)
A tiny runnable example shows send, receive and blocking, the base of everything else.
- Concurrency in Go: Goroutines and Channels Explained with Real Examples (article, DEV Community, 20 min)
It covers WaitGroups, buffered versus unbuffered channels and common pitfalls, with a fetch-data-concurrently example.
- Go by Example: Channel Synchronization (tutorial, Go by Example, 8 min)
It shows how to use a channel to wait for a goroutine to finish, and when a WaitGroup is better.
- Effective Go (Concurrency: Share by communicating) (doc, go.dev, 15 min)
It explains the idea behind the slogan 'share memory by communicating', so you know why channels exist.
- A Tour of Go: Select (interactive, go.dev, 10 min)
A runnable example introduces select, which waits on several channel operations at once.
- Channels and select in Go (article, Teach YourSelf Coding, 20 min)
It adds non-blocking select with default and the done-channel pattern for stopping a goroutine.
- Go Concurrency Patterns (video, Rob Pike, Google I/O 2012, 52 min)
The Go team's own talk builds generators, fan-in, timeouts and select step by step.
- Go by Example: Worker Pools (tutorial, Go by Example, 12 min)
You apply goroutines, channels and close to a standard fixed-size worker pool.
- Go Concurrency Patterns: Pipelines and cancellation (article, The Go Blog, 30 min)
It covers pipeline stages, closing channels and cancelling with select, which prevents goroutine leaks.
- concurrency patterns (repo, GoBridge (GitHub), 30 min)
Runnable code from Rob Pike's talk lets you modify the patterns and test your understanding.