diff options
| author | Daniel Martí <mvdan@mvdan.cc> | 2018-05-04 10:10:59 +0700 |
|---|---|---|
| committer | Daniel Martí <mvdan@mvdan.cc> | 2018-05-04 23:25:17 +0000 |
| commit | d0ed8d6ea161f89880e057fe54fa4825df4097b9 (patch) | |
| tree | ace50fdc6ac80a035e95968f11fb764b8da4eb7d /src | |
| parent | 2aef675000e71daeef77c0fb3379bcd142e48959 (diff) | |
| download | go-d0ed8d6ea161f89880e057fe54fa4825df4097b9.tar.xz | |
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: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Rob Pike <r@golang.org>
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmd/vet/print.go | 2 | ||||
| -rw-r--r-- | src/cmd/vet/testdata/print.go | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/src/cmd/vet/print.go b/src/cmd/vet/print.go index e4e99641ef..6728d88d45 100644 --- a/src/cmd/vet/print.go +++ b/src/cmd/vet/print.go @@ -721,7 +721,7 @@ const ( flagsRE = `[+\-#]*` indexOptRE = `(\[[0-9]+\])?` numOptRE = `([0-9]+|` + indexOptRE + `\*)?` - verbRE = `[bcdefgopqstvxEFGUX]` + verbRE = `[bcdefgopqstvxEFGTUX]` ) // checkPrint checks a call to an unformatted print routine such as Println. diff --git a/src/cmd/vet/testdata/print.go b/src/cmd/vet/testdata/print.go index 459b08141b..34f4e2865a 100644 --- a/src/cmd/vet/testdata/print.go +++ b/src/cmd/vet/testdata/print.go @@ -148,6 +148,7 @@ func PrintfTests() { fmt.Println() // not an error 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("%T", "hi") // ERROR "Println call has possible formatting directive %T" 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.Sprintf("%"+("s"), "hi", 3) // ERROR "Sprintf call needs 1 arg but has 2 args" |
