]> Cypherpunks repositories - gostls13.git/commit
cmd/vet: report uncalled functions in Printf %v
authorRuss Cox <rsc@golang.org>
Fri, 29 Jan 2016 15:16:24 +0000 (10:16 -0500)
committerRuss Cox <rsc@golang.org>
Fri, 29 Jan 2016 17:01:47 +0000 (17:01 +0000)
commit0f89efa255a46eb6528d27c920030721ae68b507
tree7690d76abe32a048c94842cad6693bb9c71fbd87
parent2e08694d51490339d7ffc05add0f16bb6c443013
cmd/vet: report uncalled functions in Printf %v

Given, say, var f *os.File, a new vet check in CL 14122 diagnoses:

fmt.Printf("%s\n", f.Name)
fmt.Println(f.Name)

but not

fmt.Printf("%v\n", f.Name)

In all three cases the error is that the argument should be f.Name().

Diagnosing Println but not Printf %v seems oddly inconsistent,
so I changed %v to have the check too. In fact, all verbs now have
the check except %p and %T.

Fixes Dave Cheney's confusion when trying to write an example
of the new vet check advertised in the Go 1.6 release notes.

Change-Id: I92fa6a7a1d5d9339a6a59ae4e587a254e633f500
Reviewed-on: https://go-review.googlesource.com/19101
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
src/cmd/vet/print.go
src/cmd/vet/testdata/print.go