Go channels revisited
Once the select keyword comes into play, Go channels can be used in several unique ways to do many more things than those you experienced in Chapter 9, Concurrency in Go – Goroutines, Channels, and Pipelines. This section will reveal the many uses of Go channels.
It helps to remember that the zero value of the channel type is nil, and that if you send a message to a closed channel, the program will panic. However, if you try to read from a closed channel, you will get the zero value of the type of that channel. So, after closing a channel, you can no longer write to it, but you can still read from it.
In order to be able to close a channel, the channel must not be receive-only. Additionally, a nil channel always blocks, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access