This little pattern may also be useful:

ticket := make(chan bool, 1)
ticket <- true
close(ticket)

Now, first read from ticket will yield true, all subsequent reads will 
yield false.
So any number of go-routines can do this if, but the call to close will 
happen at most once:

if (<-ticket) {
    close(myChannel)
}

br. Chr.

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to