Buffering
By default, channels are buffered, which means they will only accept submissions (chan
<-) if there is a matching receive (<- chan) that is ready to receive the submitted value.
Buffered channels allow you to accept a limited number of values without a corresponding receiver for those values.
It is possible to create a channel with a buffer. Buffered channels are only blocked when the buffer is full. Likewise, receipts from a buffered channel are only blocked when the buffer is full.
empty.
Buffered channels can be created by passing an additional capacity parameter to the make() function that specifies the size of the buffer.
ch := make(chan type, capacity)