I believe this is a false positive as well:
ctx, cancel := context.WithCancel(tl.ctx)
job := &ActiveJob{ctx: ctx, cancel: cancel, ...}
go func(job *ActiveJob) {
defer func() {
if r := recover(); r != nil {
logger.Error("panic",
zap.Any("error", r),
zap.String("stack", string(debug.Stack())))
}
}()
logger.Info("running",
zap.Object("job", row),
zap.String("state", string(row.State)))
defer job.cancel() // <-- cancel is called reliably here
// ...
})(job)
The cancel() function is called reliably. I do not think it merits a lint error.
I believe this is a false positive as well:
The
cancel()function is called reliably. I do not think it merits a lint error.