Re:Practical nil panic detection for Go
by pigeonhole123 on Saturday November 18, 2023 @01:51PM
(#38323010)
Not only that but those behaviors are patently not footguns or unreasonable in any way
[ Parent
| on HN ]
Re:Practical nil panic detection for Go
by insanitybit on Saturday November 18, 2023 @07:34PM
(#38326823)
> "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.
Re:Practical nil panic detection for Go
by usrbinbash on Sunday November 19, 2023 @05:07AM
(#38331124)
Goroutines 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.