cmd/vet: -lostcancel: check for discarded result of context.WithCancel
The cfg subpackage builds a control flow graph of ast.Nodes. The lostcancel module checks this graph to find paths, from a call to WithCancel to a return statement, on which the cancel variable is not used. (A trivial case is simply assigning the cancel result to the blank identifier.) In a sample of 50,000 source files, the new check found 2068 blank assignments and 118 return-before-cancel errors. I manually inspected 20 of the latter and didn't find a single false positive among them. Change-Id: I84cd49445f9f8d04908b04881eb1496a96611205 Reviewed-on: https://go-review.googlesource.com/24150Reviewed-by: Robert Griesemer <gri@golang.org> Reviewed-by: Rob Pike <r@golang.org>
Showing
This diff is collapsed.
src/cmd/vet/lostcancel.go
0 → 100644
Please register or sign in to comment