nil channel in select blocks forever, why no error
Spent an embarrassing amount of time on this. I had a var ch chan int that I forgot to initialize, then a select with case v := <-ch:. It just sat there, no panic, no error, the whole function hung. Turns out a nil channel in a select is simply disabled. Is this documented behavior and how do people avoid getting bitten by it?
4 replies