should I care about closing/cancelling channel during object teardown if it's used only internally in the object and coroutine scope to operate it was already cancelled?
🚫 1
f
fatih
04/18/2020, 10:54 AM
Since the coroutine which is using to operate that is also cancelled and you are sure that that channel is no longer being used, I think you don't need to care about it
👍 1
e
Erik
04/18/2020, 4:32 PM
Channels are a communication primitive between coroutines, but need not to be closed if the coroutines are no longer active. Closing a channel is useful for other things, but is not necessary in your case.
Channels are not tied to any native resource and they don't have to be closed to release their memory. Simply dropping all the references to a channel is fine. GC will come to do clean it up.