3 ms·
Not only that but those behaviors are patently not footguns or unreasonable in any way
by pigeonhole123 3y ago
Not only that but those behaviors are patently not footguns or unreasonable in any way
- deleted 3y ago[deleted]
- insanitybit 3y 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.
- usrbinbash 3y agoGoroutines blocking is normal procedure in a a Go program. It also isn't a problem, unless my code is broken and allows all Goroutines to block simultaneously...in which case the runtime automatically terminates the program with a Deadlock-Panic. 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.