unusedresult.go: Include context.With* functions
This commit includes the four "With" functions from the context package in the
list of unused functions. This will produce the following error:
./main.go:9:19: result of context.WithValue call not used
When analyzing this:
```go
func f(ctx context.Context) {
context.WithValue(ctx, "foo", -6)
}
```
Fixes golang/go#41149
Change-Id: I5456b79396d45d15498070b5184d5de8c257b343
GitHub-Last-Rev: 577c6b380690477280ed6e941f9dee2057af90f3
GitHub-Pull-Request: golang/tools#248
Reviewed-on: https://go-review.googlesource.com/c/tools/+/252057
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
diff --git a/go/analysis/passes/unusedresult/unusedresult.go b/go/analysis/passes/unusedresult/unusedresult.go
index 76d4ab2..bececee 100644
--- a/go/analysis/passes/unusedresult/unusedresult.go
+++ b/go/analysis/passes/unusedresult/unusedresult.go
@@ -44,7 +44,7 @@
func init() {
// TODO(adonovan): provide a comment syntax to allow users to
// add their functions to this set using facts.
- funcs.Set("errors.New,fmt.Errorf,fmt.Sprintf,fmt.Sprint,sort.Reverse")
+ funcs.Set("errors.New,fmt.Errorf,fmt.Sprintf,fmt.Sprint,sort.Reverse,context.WithValue,context.WithCancel,context.WithDeadline,context.WithTimeout")
Analyzer.Flags.Var(&funcs, "funcs",
"comma-separated list of functions whose results must be used")