Hacker News new | ask | show | jobs
by Thorrez 658 days ago
Can't channels deadlock too? Sending or receiving on a channel will block by default until the other side receives/sends the value if the channel is unbuffered, or it's buffered but the buffer is full. You have to write extra code to make it non-blocking; the pubsub example under discussion is blocking. I don't see how switching the discussed code to a mutex would make it any more blocking or deadlock prone.

I found a bug in production caused by the author not realizing a send on a channel can block.