3 ms·
The explanation of the issue in ToDoneInterface really is not clear to me because of this: > The defer close() seems to close well, but it’s on the wrong chann
by masklinn 3y ago
The explanation of the issue in ToDoneInterface really is not clear to me because of this:
> The defer close() seems to close well, but it’s on the wrong channel.
The `done` input channel is supposed to be closed by a caller, and the goroutine is closing the output channel, surely that's the point?
Now from what I know of go channels and understand of the code involved, the `done` channel may never get closed by the parents (and can never get closed at all if it's nil?), in which case the goroutine never receives a signal, never terminates, and leaks. But the explanation below the snippet confuses me completely.
And if that's that... what's the fix? Aside from not doing this sort of conversions? Just "git good scrub", try to make sure you don't rely on cancellation for progress, and hope you don't use raw background channels again, and don't forget to cancel your non-background channels?