clause (which just consumes the value) and a default clause (which exits
the loop). The goal is to drain a channel of all items.
There are several goroutines that are blocked on sending to the channel (it
has a small capacity, but there are many more senders).
My confusion is about the implementation of the default branch of select.
I was expecting that when the receive clause ran out of items to read from
the channel, instead of going down the default clause, we would fire up
some of the routines blocked on sending to the channel.
See http://play.golang.org/p/iO9M9FLDWw which exits after 10 values, rather
than the 100 I had expected.
If instead I replace the default case by a timer, I see my expected
Can someone with more experience than me in the language design explain the
rationale of the default branch evaluation, and also weigh in on whether
there is a better solution than a timer?
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firstname.lastname@example.org.
For more options, visit https://groups.google.com/groups/opt_out.