4 ms·
> Unless I've missed it in my reading, I don't see any of these clearly stating that the single-return form of channel receive will fabricate zero values when m
by tapirl 5y ago
> Unless I've missed it in my reading, I don't see any of these clearly stating that the single-return form of channel receive will fabricate zero values when misused, or describing how you need to replace a closed channel with a nil when selecting on multiple channels to avoid spinning the CPU when it's been closed.
You certainly missed this: https://golang.org/ref/spec#Close https://golang.org/ref/spec#Close
You might also need read https://blog.golang.org/pipelines https://blog.golang.org/pipelines and https://blog.golang.org/concurrency-timeouts https://blog.golang.org/concurrency-timeouts
If you need a good summary, you could read my articles:
* https://go101.org/article/channel.html https://go101.org/article/channel.html
* https://go101.org/article/channel-use-cases.html https://go101.org/article/channel-use-cases.html
* https://go101.org/article/channel-closing.html https://go101.org/article/channel-closing.html