1
0
mirror of https://github.com/golang/go synced 2024-11-19 15:05:00 -07:00

fmt: hide bad format in test from vet

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>
This commit is contained in:
Russ Cox 2017-10-30 23:14:21 -04:00
parent 9364c0e337
commit 8f4f1f63e9
2 changed files with 3 additions and 4 deletions

View 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

View 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)