mirror of
https://github.com/golang/go
synced 2024-11-18 16:44:43 -07:00
go/analysis/passes/printf: allow %x/%X for float/complex types
These verbs are supported as of Go 1.13. Updates golang/go#34993 Change-Id: Ib7892e45b51073e3771bebb652a8fe3a1c6ae3c6 Reviewed-on: https://go-review.googlesource.com/c/tools/+/202041 Run-TryBot: Caleb Spare <cespare@gmail.com> Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
parent
a1005cf9b2
commit
04252eccb9
@ -766,8 +766,8 @@ var printVerbs = []printVerb{
|
||||
{'U', "-#", argRune | argInt},
|
||||
{'v', allFlags, anyType},
|
||||
{'w', allFlags, argError},
|
||||
{'x', sharpNumFlag, argRune | argInt | argString | argPointer},
|
||||
{'X', sharpNumFlag, argRune | argInt | argString | argPointer},
|
||||
{'x', sharpNumFlag, argRune | argInt | argString | argPointer | argFloat | argComplex},
|
||||
{'X', sharpNumFlag, argRune | argInt | argString | argPointer | argFloat | argComplex},
|
||||
}
|
||||
|
||||
// okPrintfArg compares the formatState to the arguments actually present,
|
||||
|
@ -84,8 +84,8 @@ func PrintfTests() {
|
||||
fmt.Printf("%T %T", 3, i)
|
||||
fmt.Printf("%U %U", 3, i)
|
||||
fmt.Printf("%v %v", 3, i)
|
||||
fmt.Printf("%x %x %x %x", 3, i, "hi", s)
|
||||
fmt.Printf("%X %X %X %X", 3, i, "hi", s)
|
||||
fmt.Printf("%x %x %x %x %x %x %x", 3, i, "hi", s, x, c, fslice)
|
||||
fmt.Printf("%X %X %X %X %X %X %X", 3, i, "hi", s, x, c, fslice)
|
||||
fmt.Printf("%.*s %d %g", 3, "hi", 23, 2.3)
|
||||
fmt.Printf("%s", &stringerv)
|
||||
fmt.Printf("%v", &stringerv)
|
||||
@ -128,7 +128,6 @@ func PrintfTests() {
|
||||
fmt.Printf("%t", 23) // want "Printf format %t has arg 23 of wrong type int"
|
||||
fmt.Printf("%U", x) // want "Printf format %U has arg x of wrong type float64"
|
||||
fmt.Printf("%x", nil) // want "Printf format %x has arg nil of wrong type untyped nil"
|
||||
fmt.Printf("%X", 2.3) // want "Printf format %X has arg 2.3 of wrong type float64"
|
||||
fmt.Printf("%s", stringerv) // want "Printf format %s has arg stringerv of wrong type a.ptrStringer"
|
||||
fmt.Printf("%t", stringerv) // want "Printf format %t has arg stringerv of wrong type a.ptrStringer"
|
||||
fmt.Printf("%s", embeddedStringerv) // want "Printf format %s has arg embeddedStringerv of wrong type a.embeddedStringer"
|
||||
|
Loading…
Reference in New Issue
Block a user