Buffered channels store values in memory to prevent blocking, while unbuffered channels require immediate synchronization between sender and receiver.
Buffered channels hold a fixed number of values in memory, while unbuffered channels block the sender until a receiver is ready. Use buffered channels to decouple producers from consumers, but use unbuffered channels for strict synchronization or to prevent signal loss in signal.Notify.
// Unbuffered: Sender blocks until receiver reads
ch := make(chan int)
// Buffered: Sender proceeds until buffer (capacity 1) is full
ch := make(chan int, 1)
An unbuffered channel is like a direct handoff where the giver must wait for the receiver to take the item before moving on. A buffered channel is like a mailbox where the giver can drop items in and leave, as long as the box isn't full. You use unbuffered channels to force two parts of your code to talk at the exact same time, and buffered channels to let them work at their own pace.