Commit d0ed8d6e authored by Daniel Martí's avatar Daniel Martí

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 #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: default avatarJosh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: default avatarRob Pike <r@golang.org>
parent 2aef6750
...@@ -721,7 +721,7 @@ const ( ...@@ -721,7 +721,7 @@ const (
flagsRE = `[+\-#]*` flagsRE = `[+\-#]*`
indexOptRE = `(\[[0-9]+\])?` indexOptRE = `(\[[0-9]+\])?`
numOptRE = `([0-9]+|` + indexOptRE + `\*)?` numOptRE = `([0-9]+|` + indexOptRE + `\*)?`
verbRE = `[bcdefgopqstvxEFGUX]` verbRE = `[bcdefgopqstvxEFGTUX]`
) )
// checkPrint checks a call to an unformatted print routine such as Println. // checkPrint checks a call to an unformatted print routine such as Println.
......
...@@ -148,6 +148,7 @@ func PrintfTests() { ...@@ -148,6 +148,7 @@ func PrintfTests() {
fmt.Println() // not an error fmt.Println() // not an error
fmt.Println("%s", "hi") // ERROR "Println call has possible formatting directive %s" fmt.Println("%s", "hi") // ERROR "Println call has possible formatting directive %s"
fmt.Println("%v", "hi") // ERROR "Println call has possible formatting directive %v" fmt.Println("%v", "hi") // ERROR "Println call has possible formatting directive %v"
fmt.Println("%T", "hi") // ERROR "Println call has possible formatting directive %T"
fmt.Println("0.0%") // correct (trailing % couldn't be a formatting directive) fmt.Println("0.0%") // correct (trailing % couldn't be a formatting directive)
fmt.Printf("%s", "hi", 3) // ERROR "Printf call needs 1 arg but has 2 args" fmt.Printf("%s", "hi", 3) // ERROR "Printf call needs 1 arg but has 2 args"
_ = fmt.Sprintf("%"+("s"), "hi", 3) // ERROR "Sprintf call needs 1 arg but has 2 args" _ = fmt.Sprintf("%"+("s"), "hi", 3) // ERROR "Sprintf call needs 1 arg but has 2 args"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment