Hello,
I'm having go vet complain about the cancelFunc on a context.WithTimeout
not being called, even though the flow path is already past the context
.Done()
Something like:
ctx, cancel := context.WithTimeout(parentCtx, timeout)
select {
case <-ctx.Done():
//... go vet complains here that this flowpath doesnt call cancel()
return nil
case msg := <-ch:
//...
cancel()
return msg
}
Reading context/context.go:
// Failing to call the CancelFunc leaks the
// child and its children until the parent is canceled or the timer
// fires. The go vet tool checks that CancelFuncs are used on all
// control-flow paths.
I know in this example I could just defer the call but, should I consider
this a false positive? Should I open an issue on github?
Best regards
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.