For why close the error channel: Because if you don't close the error channel, the last return statement maybe blocked forever if there is no value in the chan. Receive from a closed chan will return immediately even if it's empty.
Because if you don't close the error channel, the last return statement maybe blocked forever if there is no value in the chan. Receive from a closed chan will return immediately even if it's empty.
For why close the error channel: Because if you don't close the error channel, the last return statement maybe blocked forever if there is no value in the chan. Receive from a closed chan will return immediately even if it's empty.
Minor, but could sem not have been a chan struct{} instead of a chan int?
nice sharing.
hi, why did you not close the error channel as well?
Same question. Any idea why?
Because if you don't close the error channel, the last return statement maybe blocked forever if there is no value in the chan. Receive from a closed chan will return immediately even if it's empty.
Thanks Fengin
By the way Dave Cheney is a great author - dave.cheney.net/!
fatal error: all goroutines are asleep - deadlock!
i think it's OK if not close errchan