Skip to content

Commit d0ed8d6

Browse files
committed
cmd/vet: %T is a formatting directive too
Some warnings were being missed, because vet's regex that finds formatting directives was missing the 'T' verb. Fixes golang#24646. Change-Id: I2f6f9ed19e7daf9a07175199f428a62e94799ea9 Reviewed-on: https://go-review.googlesource.com/111357 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Rob Pike <r@golang.org>
1 parent 2aef675 commit d0ed8d6

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/cmd/vet/print.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ const (
721721
flagsRE = `[+\-#]*`
722722
indexOptRE = `(\[[0-9]+\])?`
723723
numOptRE = `([0-9]+|` + indexOptRE + `\*)?`
724-
verbRE = `[bcdefgopqstvxEFGUX]`
724+
verbRE = `[bcdefgopqstvxEFGTUX]`
725725
)
726726

727727
// checkPrint checks a call to an unformatted print routine such as Println.

src/cmd/vet/testdata/print.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ func PrintfTests() {
148148
fmt.Println() // not an error
149149
fmt.Println("%s", "hi") // ERROR "Println call has possible formatting directive %s"
150150
fmt.Println("%v", "hi") // ERROR "Println call has possible formatting directive %v"
151+
fmt.Println("%T", "hi") // ERROR "Println call has possible formatting directive %T"
151152
fmt.Println("0.0%") // correct (trailing % couldn't be a formatting directive)
152153
fmt.Printf("%s", "hi", 3) // ERROR "Printf call needs 1 arg but has 2 args"
153154
_ = fmt.Sprintf("%"+("s"), "hi", 3) // ERROR "Sprintf call needs 1 arg but has 2 args"

0 commit comments

Comments
 (0)