I'm going through Go by Example: Non-Blocking Channel Operations
As far as I understand, the first select is triggering the default case because there are nothing in the messages channel, and if the default case didn't exist, we would receive a fatal error: all goroutines are asleep - deadlock! error, right?
Well, I cannot figure out how can I trigger the second select, specifically trigger the case messages <- msg:
As I thought, it should work opposite to the receive. So if there's a buffer for 2 messages and we send the 3rd message to the channel, it would trigger the default clause, but the messages channel is empty, so why in the second select does it trigger the default clause? And how can I trigger the case messages <- msg: clause?