So, I just found out that closed channels always yield the zero value. That 
means, a closed channel inside a select statement seems to always be 
guaranteed to be executed.

Since closing an already closed channel creates a panic, does this mean 
then I can do this to make sure that the channel is closed only once?


select {
    case <- closedchan:
    default:
        close(closedchan)
}



Golang playground: https://play.golang.org/p/LSrTh0HC2K

It seems to work. Just want to confirm here before start doing this 
everywhere in my code.

-- 
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