Skip to content

Concurrency

Go's defining feature. Concurrency is built into the language with goroutines and channels as first-class citizens. This section covers everything from launching your first goroutine to production-grade concurrent architectures.


# Topic What You'll Learn Level
1 Goroutines Lightweight threads, GMP scheduler, goroutine leaks, lifecycle Intermediate
2 Channels Buffered/unbuffered, directional, closing, channel axioms Intermediate
3 Select Statement Multiplexing, timeouts, non-blocking ops, nil channel trick Intermediate
4 Sync Package Mutex, RWMutex, WaitGroup, Once, Pool, Map Intermediate
5 Context Package Cancellation, deadlines, values, request-scoped propagation Intermediate
6 Concurrency Patterns Pipeline, fan-in/out, worker pool, semaphore, errgroup Advanced
7 Channel Patterns & Idioms Done channel, or-channel, tee, bridge, pub/sub Advanced
8 Race Condition Detection -race flag, data races, sync/atomic, prevention strategies Advanced
9 Memory Model Happens-before guarantees, ordering, visibility rules Advanced

Interview Quick Hits

  • "Concurrency is not parallelism" -- Rob Pike. Know the difference.
  • Goroutines cost ~2KB of stack, dynamically grown. You can run millions.
  • Channel axioms: send to nil blocks, receive from nil blocks, send to closed panics, receive from closed returns zero
  • Context is how Go propagates cancellation and deadlines across API boundaries
  • The -race flag uses ThreadSanitizer and catches data races at runtime -- always use in CI
  • Worker pool is the most commonly asked concurrency pattern in interviews