x/tools/analysis: printf pass should only allow %w in fmt.Errorf #37792
Labels
FrozenDueToAge
Tools
This label describes issues relating to any tools in the x/tools repository.
WaitingForInfo
Issue is not actionable because of missing required information, which needs to be provided.
Milestone
Seems like currently all functions which are called
Errorf
are created in the same way: https://github.com/golang/tools/blob/aafaee8bce8c38f7ce09907ff7430abcb6f58132/go/analysis/passes/printf/printf.go#L493-L495. However, onlyfmt.Errorf
accepts%w
in the standard library.The way it is causes problems with exceptions to this rule. One notable one is github.com/pkg/errors. There
%w
doesn't make sense in the call toerrors.Errorf
: https://godoc.org/github.com/pkg/errors#Errorf.Consider making that check more specific and treat
fmt.Errorf
differently from regular functions calledErrorf
.I guess golang/tools@1d17272 should be extended.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Wrote a program that uses
github.com/pkg/errors.Errorf
and used the%w
verb in there. Rango vet
on it and expected theprintf
analysis to report errors but there were none.What did you expect to see?
Errors that
%w
verb is unsupported with that function.What did you see instead?
Success of
go vet
.The text was updated successfully, but these errors were encountered: