The guarantee of delivery
The main difference between buffered and unbuffered channels is the guarantee of delivery.
As we saw earlier, the unbuffered channels always guarantee delivery, since they only send a message when the receiver is ready. Conversely, the buffered channels can’t ensure message delivery because they can “buffer” an arbitrary number of messages before the synchronization step becomes mandatory. Therefore, the reader could fail to read a message from the channel buffer.
The most considerable side effect of choosing between them is how much latency you can afford to introduce to your program.
Latency
Latency in the context of concurrent programming refers to the time it takes for a piece of data to travel from a sender (goroutine) to a receiver (goroutine) through a channel.
In Go channels, latency is influenced by several factors:
- Buffering: Buffering can reduce latency when the sender and receiver are not perfectly synchronized...