Using Go 1.4 and latest tools subrepo:
~ $ go version
go version go1.4 darwin/amd64
~ $ gostatus -v ...cmd/vet
golang.org/x/tools/...
By default, vet is supposed to detect "Suspicious calls to functions in the Printf family." I've noticed that it sometimes did not do that reliably (it would detect some cases but not others). I wrote the following .go file that reproduces the issue for me:
package main
import (
"log"
"net/url"
"golang.org/x/oauth2"
)
func main() {
thirdParty := oauth2.Config{
ClientID: "some-string", // A string.
}
stdLib := url.URL{
Path: "some-string", // A string.
}
log.Printf("Hello, %d.\n", thirdParty.ClientID) // go vet does _not_ catch this.
log.Printf("Hello, %d.\n", stdLib.Path) // But it catches this.
}
What did you expect to see?
Both printf verb usage issues should be reported, not just one.
main.go:18: arg thirdParty.ClientID for printf verb %d of wrong type: string
main.go:19: arg stdLib.Path for printf verb %d of wrong type: string
What did you see instead?
Here is my output of vet on that file/package:
main.go:19: arg stdLib.Path for printf verb %d of wrong type: string
It detects the bad printf verb usage for a string type from standard library, but not external library.
It would be great if vet were more reliable, so I could depend on it to catch all printf verb misuse when possible (and it's certainly possible here).
Using Go 1.4 and latest tools subrepo:
By default,
vetis supposed to detect "Suspicious calls to functions in the Printf family." I've noticed that it sometimes did not do that reliably (it would detect some cases but not others). I wrote the following .go file that reproduces the issue for me:What did you expect to see?
Both printf verb usage issues should be reported, not just one.
What did you see instead?
Here is my output of
veton that file/package:It detects the bad printf verb usage for a string type from standard library, but not external library.
It would be great if
vetwere more reliable, so I could depend on it to catch all printf verb misuse when possible (and it's certainly possible here).