March 2019
Beginner to intermediate
324 pages
7h 17m
English
A buffered channel is a special type of channel that holds a buffer that contains a number of items. Unlike a regular channel, a buffered channel doesn't block unless the following takes place:
To declare a buffered channel, we use the following syntax:
myBufferedChannel := make(chan int,10)
The preceding syntax creates a buffered channel that can hold 10 int values.
To send a value to the buffered channel, we use the same syntax as with regular channels. Each send operation adds one item to the buffer, as follows:
myBufferedChannel <- 10
To receive a value from a buffered channel, ...
Read now
Unlock full access