I find the pattern
for {
select {
val := <- someChan
doSomething(val)
}
}
for single channel reads very common. I don't like this pattern because you can't close the channel, which is a useful way of signalling you want the routine to end. I guess you could add a signal channel in that select block too, but the language supports "auto exit loop" on close already, via the range functionInstead:
for val := range someChan {
doSomething(val)
}
It might be subjective but1. It reads better
2. It leaves the loop when you call close(someChan), which is neat
But that's just my take. I'd be curious if anyone has any reasons for the single-channel-read-in-a-select-block approach