]> Cypherpunks repositories - gostls13.git/commitdiff
fmt: hide bad format in test from vet
authorRuss Cox <rsc@golang.org>
Tue, 31 Oct 2017 03:14:21 +0000 (23:14 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 31 Oct 2017 13:49:53 +0000 (13:49 +0000)
Hide in the source code instead of in the separate whitelist.
Removes the only printf false positive in the standard library.

Change-Id: I99285e67588c7c93bd56d59ee768a03be7c301e7
Reviewed-on: https://go-review.googlesource.com/74590
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
src/cmd/vet/all/whitelist/all.txt
src/fmt/fmt_test.go

index 5467db98806c094b607168a3926b3a41d5bc703d..98415ef056832bc20606ea867571b974cd932ae3 100644 (file)
@@ -13,9 +13,6 @@ go/types/scope.go: method WriteTo(w io.Writer, n int, recurse bool) should have
 
 // False positives.
 
-// Test of how fmt handles nil.
-fmt/fmt_test.go: arg nil for printf verb %s of wrong type: untyped nil
-
 // Nothing much to do about cross-package assembly. Unfortunate.
 runtime/asm_ARCHSUFF.s: [GOARCH] cannot check cross-package assembly function: call is in package reflect
 runtime/asm_ARCHSUFF.s: [GOARCH] cannot check cross-package assembly function: Equal is in package bytes
index 0e09f16dbfb80e6b98d815eb800618bc66aa161a..08e46b4e935425429be8589c444aa8bb38dd1dbf 100644 (file)
@@ -1733,12 +1733,14 @@ func TestIsSpace(t *testing.T) {
        }
 }
 
+func hideFromVet(s string) string { return s }
+
 func TestNilDoesNotBecomeTyped(t *testing.T) {
        type A struct{}
        type B struct{}
        var a *A = nil
        var b B = B{}
-       got := Sprintf("%s %s %s %s %s", nil, a, nil, b, nil) // go vet should complain about this line.
+       got := Sprintf(hideFromVet("%s %s %s %s %s"), nil, a, nil, b, nil)
        const expect = "%!s(<nil>) %!s(*fmt_test.A=<nil>) %!s(<nil>) {} %!s(<nil>)"
        if got != expect {
                t.Errorf("expected:\n\t%q\ngot:\n\t%q", expect, got)