Commit 8f4f1f63 authored by Russ Cox's avatar Russ Cox

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: 's avatarRob Pike <r@golang.org>
parent 9364c0e3
......@@ -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
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment