1
0
mirror of https://github.com/golang/go synced 2024-11-18 04:54:49 -07:00

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>
This commit is contained in:
Mark Dain 2020-09-01 08:26:47 +00:00 committed by Rebecca Stambler
parent fd8950f6eb
commit 6e59e24738

View File

@ -44,7 +44,7 @@ var funcs, stringMethods stringSetFlag
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")