09 / 10

What is the difference between a buffered and unbuffered channel?

An unbuffered channel synchronizes sender and receiver — both must be ready simultaneously. A buffered channel decouples them up to the buffer capacity, after which the sender blocks.

Buffered vs unbuffered channels
When to use each
  1. 1

    Unbuffered: guaranteed handoff, synchronization points, request-reply patterns

  2. 2

    Buffered: decouple producer and consumer speeds, absorb bursts, pipeline stages

  3. 3

    Buffered channels are NOT a substitute for proper back-pressure — a full buffer that never drains causes goroutine leaks

  4. 4

    Rule of thumb: start with unbuffered, add buffer only when profiling shows unnecessary blocking

  5. 5

    Closing a channel signals no more values — receivers drain remaining buffered values before seeing the zero value