cmd/vet: false positive printf detection for URL-encoded /
(%2F
) in string literal
#29854
Labels
Analysis
Issues related to static analysis (vet, x/tools/go/analysis)
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone
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?
Using the logging library github.com/spf13/jwalterweatherman, I have this line in our logs:
This is supposed to print a URL to console that the user can click to go to the logs. Since the URL includes a slash-separated string as a parameter, those slashes have to be URL-encoded, which for a forward slach is
%2F
.What did you expect to see?
No vet error
What did you see instead?
vet fires an error:
Normally this wouldn't be an issue, but as of Go 1.10,
go test
now runsgo vet
natively with a hardcoded list of checks, and the only option is to either convert this to a Printf and doubling the percent signs to escape them, or disablego vet
duringgo test
, neither of which is a fantastic solution.Recommendations / possible resolutions:
f
call and neglected to include the value to replace it with in the formatted string).go test
automatic run ofgo vet
, possibly via a flag like-vetflags="-printf=false"
. This would also allow any of the other vet-specific flags to be passed down to it.The text was updated successfully, but these errors were encountered: