diff --git a/cmd/vet/print.go b/cmd/vet/print.go index 3dda32837c..cf318cc09e 100644 --- a/cmd/vet/print.go +++ b/cmd/vet/print.go @@ -459,7 +459,7 @@ func (f *File) argCanBeChecked(call *ast.CallExpr, formatArg int, isStar bool, s } // This is the argument number relative to the format: Printf("%s", "hi") will give 1 for the "hi". arg := argNum - state.firstArg + 1 // People think of arguments as 1-indexed. - f.Badf(call.Pos(), "missing argument for %s %s: need %d, only have %d", state.name, verb, arg, len(call.Args)-state.firstArg) + f.Badf(call.Pos(), "missing argument for %s %s: need %d, have %d", state.name, verb, arg, len(call.Args)-state.firstArg) return false } diff --git a/cmd/vet/testdata/print.go b/cmd/vet/testdata/print.go index 26f13f51d5..6884ca741b 100644 --- a/cmd/vet/testdata/print.go +++ b/cmd/vet/testdata/print.go @@ -118,7 +118,7 @@ func PrintfTests() { Printf("hi") // ok const format = "%s %s\n" Printf(format, "hi", "there") - Printf(format, "hi") // ERROR "missing argument for Printf verb %s: need 2, only have 1" + Printf(format, "hi") // ERROR "missing argument for Printf verb %s: need 2, have 1" f := new(stringer) f.Warn(0, "%s", "hello", 3) // ERROR "possible formatting directive in Warn call" f.Warnf(0, "%s", "hello", 3) // ERROR "wrong number of args for format in Warnf call" @@ -134,8 +134,8 @@ func PrintfTests() { // Bad argument reorderings. Printf("%[xd", 3) // ERROR "illegal syntax for printf argument index" Printf("%[x]d", 3) // ERROR "illegal syntax for printf argument index" - Printf("%[3]*s", "hi", 2) // ERROR "missing argument for Printf indirect \*: need 3, only have 2" - fmt.Sprintf("%[3]d", 2) // ERROR "missing argument for Sprintf verb %d: need 3, only have 1" + Printf("%[3]*s", "hi", 2) // ERROR "missing argument for Printf indirect \*: need 3, have 2" + fmt.Sprintf("%[3]d", 2) // ERROR "missing argument for Sprintf verb %d: need 3, have 1" Printf("%[2]*.[1]*[3]d", 2, "hi", 4) // ERROR "arg .hi. for \* in printf format not of type int" // Something that satisfies the error interface. var e error