In general you can use the race detector to help answer this sort of question, although it does not detect all races.
Unfortunately, it doesn't detect this one. (I've filed https://golang.org/issue/22569, because I think it should.) On Friday, November 3, 2017 at 4:08:19 AM UTC-4, sheepbao wrote: > > Thanks, I got it. > > On Friday, November 3, 2017 at 11:26:31 AM UTC+8, Jesse McNelis wrote: >> >> On Thu, Nov 2, 2017 at 4:54 PM, sheepbao <listo...@gmail.com> wrote: >> > >> > the close function is thread safety? how about call `closed` at the >> same >> > time. >> >> It's not safe. Multiple goroutines can enter the 'default' case in >> that select and close() the channel multiple times. >> >> "Sending to or closing a closed channel causes a run-time panic." >> https://golang.org/ref/spec#Close >> > -- 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.