Goroutines, channels and select: your first concurrent Go

12 steps · about 4 h 3 min · Intermediate

  1. Concurrency is not parallelism (article, The Go Blog, 8 min)

    It separates concurrency from parallelism first, so the later syntax makes sense.

  2. 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.

  3. Go by Example: Channels (tutorial, Go by Example, 8 min)

    A tiny runnable example shows send, receive and blocking, the base of everything else.

  4. 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.

  5. 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.

  6. 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.

  7. A Tour of Go: Select (interactive, go.dev, 10 min)

    A runnable example introduces select, which waits on several channel operations at once.

  8. 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.

  9. 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.

  10. Go by Example: Worker Pools (tutorial, Go by Example, 12 min)

    You apply goroutines, channels and close to a standard fixed-size worker pool.

  11. 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.

  12. concurrency patterns (repo, GoBridge (GitHub), 30 min)

    Runnable code from Rob Pike's talk lets you modify the patterns and test your understanding.