You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think it's asking quite a lot for vet to be able to disentangle this code. Normally a string is either a format or it isn't. It's a reasonable assumption for vet to make. In your case a string is sometimes a format string and sometimes isn't. If you want to use vet on your code, either use "%s" with a single argument, or use a separate function when you don't want to do formatting.
My intention was not to demand that go vet supports this. I was more surprised that I can not write this code and have my tests work at the same time...
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?
I wrote a function that executes either
fmt.Printf
orfmt.Print
, based on its arguments.I am using it to generate go code
Sample: https://play.golang.org/p/Pb1JwPOmDLd
What did you expect to see?
No go vet error, as it lets my tests fail.
What did you see instead?
go vet error:
write format %s reads arg #1, but call has 0 args
Additional info
It may be related to this old issue?
The text was updated successfully, but these errors were encountered: