Closed
Description
- What version of Go are you using (
go version
)?
1.6.2 - What operating system and processor architecture are you using (
go env
)?
linux/amd64 - What did you do?
The following code:
myWrongFormatVar := "%d %d %#[1]x %#x %2.f %d %2.2f %.f %.3f %[9]*.[2]*[3]f %d %f %#[1]x %#x %[2]d %v % d"
log.Printf(myWrongFormatVar, 1, 2, 3, 4, 5, 6, 7, 8)
produces a BADINDEX
at runtime however go vet
doesn't catch it. To correct the code one should add a tenth argument to the Printf
function and all should be ok.
In fact it should catch if the function has more than 9 other arguments (besides the formatting string) but it doesn't.
The other scenario is this:
log.Printf("%d %d %#[1]x %#x %f %2.f %2.2f %.f %.3f %[3]*.[2]*[1]f %d %d %#[1]x %#x %*[2]d %v % d", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)
https://play.golang.org/p/snrXok614V
- What did you expect to see?
An error about theBADINDEX
- What did you see instead?
No error.