It depends entirely on your application, and how the various goroutines are wired together with channels.
But as a guiding principle: I'd say that anything which *sends* on a channel should close it when it's finished - whether that be due to context cancellation, or some other reason. Anything that *consumes* from a channel should keep consuming until it's closed. The consumer doesn't need to check for context cancellation, because it will stop when the channel is closed anyway. If you wrote it so that the consumer independently notices the cancellation signal and stops consuming, then you risk the sending goroutine blocking forever. -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/1d457c64-74f7-4523-8274-f3e587d960abn%40googlegroups.com.