Checking if channel has data available
Receiving on a channel blocks if there is no data in the channel.
What if you don’t want to block?
You might be tempted to check if channel has data before doing a receive.
You can’t do that in Go as it couldn’t possibly work correctly. Between the time you check for availability and the time you do a receive, some other goroutine could have picked up the value.