Stage 3 · Build
Concurrency in Depth
Channel Patterns
Fan-in, fan-out, pipelines, buffered channels, and closing protocols for safe communication.
Channel Basics
Channels are typed conduits for goroutine communication. They enforce synchronization — a send blocks until a receive is ready, and vice versa. This makes channels a powerful coordination primitive.
Buffered Channels
Buffered channels decouple senders and receivers. They are useful when you want to absorb bursts or when senders and receivers run at different speeds.
Channel Direction
Channel direction in function signatures enforces communication patterns. Send-only and receive-only channels prevent misuse at compile time.
Closing Channels
Closing a channel signals that no more values will be sent. Receivers can detect this with the ok variable. The close protocol has strict rules: only the sender should close, and close exactly once.
Closing a channel from the receiver side causes panics if any sender tries to send after the close. Only the sender should close channels. If you need multiple senders, use a WaitGroup to coordinate closing.
Multiplexing with select
select waits on multiple channel operations. It is the Go equivalent of a switch statement for channels. select blocks until one case is ready, then executes it.
Common Patterns
Mark this lesson complete to store local progress and unlock a cleaner resume path the next time you visit.