A common mistake is treating select cases like switch cases: source order does not establish priority. When multiple channel communications can proceed, Go chooses one through uniform pseudo-random selection, so execution is nondeterministic. section 9.4
Buffered channels can stop early
A loop selecting between messageCh and disconnectCh may receive only 0, 5, or 10 messages before returning. If both channels are ready, the first case is not guaranteed to win; random selection prevents starvation that fixed source-order priority could cause. section 9.4
Choose a contextual fix when disconnection must follow every message:
- Use an unbuffered message channel when a single producer must block until each message is received. section 9.4
- Use one channel carrying either a message or a disconnection notification. section 9.4
