]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/vet: expand printf flags understood by %s and %q.
authorDavid Symonds <dsymonds@golang.org>
Fri, 21 Dec 2012 02:48:36 +0000 (13:48 +1100)
committerDavid Symonds <dsymonds@golang.org>
Fri, 21 Dec 2012 02:48:36 +0000 (13:48 +1100)
Fixes #4580.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7002043

src/cmd/vet/print.go

index 0ec01721a5080188fa9137bdd5a23cd0638812e1..e8b51a2a82e6b0c20bcf28eb546262c7d587f6a2 100644 (file)
@@ -208,8 +208,8 @@ var printVerbs = []printVerb{
        {'G', numFlag},
        {'o', sharpNumFlag},
        {'p', "-#"},
-       {'q', "-+#."},
-       {'s', "-."},
+       {'q', " -+.0"},
+       {'s', " -+.0"},
        {'t', "-"},
        {'T', "-"},
        {'U', "-#"},
@@ -282,6 +282,8 @@ func BadFunctionUsedInTests() {
        fmt.Println("%s", "hi")            // ERROR "possible formatting directive in Println call"
        fmt.Printf("%s", "hi", 3)          // ERROR "wrong number of args in Printf call"
        fmt.Printf("%s%%%d", "hi", 3)      // correct
+       fmt.Printf("%08s", "woo")          // correct
+       fmt.Printf("% 8s", "woo")          // correct
        fmt.Printf("%.*d", 3, 3)           // correct
        fmt.Printf("%.*d", 3, 3, 3)        // ERROR "wrong number of args in Printf call"
        fmt.Printf("%q %q", multi()...)    // ok