|
|
|
|
|
by insanitybit
950 days ago
|
|
> "Send and receive operations on a nil channel block forver." I literally can not imagine a worse behavior than my program blocking forever. Of all of the things my program can do, short of giving remote code execution, blocking is literally the worst one I can think of. |
|
The behavior of nil-channels always blocking is on purpose, and tremendously useful in functions where we receive from multiple channels via `select`. It allows the function to easily manipulate it's own receive behavior simply by setting the local reference to the channel to `nil`.
Since `selects` can also have `default`, the resulting functions don't have to block either.