From f6a22edf6613f6638e03bfcd47d59757d18dd76f Mon Sep 17 00:00:00 2001 From: Andrew Gerrand Date: Thu, 22 Aug 2013 11:29:44 +1000 Subject: [PATCH] go.tools/cmd/vet: relax recursive stringer check For the pointer receiver x, fmt.Sprintf(*x) does not invoke x's String method. R=golang-dev, r CC=golang-dev https://golang.org/cl/12971045 --- cmd/vet/print.go | 4 ---- cmd/vet/testdata/print.go | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/cmd/vet/print.go b/cmd/vet/print.go index 64c47f1c90..c90a355738 100644 --- a/cmd/vet/print.go +++ b/cmd/vet/print.go @@ -402,10 +402,6 @@ func (f *File) recursiveStringer(arg ast.Expr) bool { switch e := arg.(type) { case *ast.Ident: obj = e.Obj - case *ast.StarExpr: - if id, ok := e.X.(*ast.Ident); ok { - obj = id.Obj - } case *ast.UnaryExpr: if id, ok := e.X.(*ast.Ident); ok && e.Op == token.AND { obj = id.Obj diff --git a/cmd/vet/testdata/print.go b/cmd/vet/testdata/print.go index 3b6a8e2461..cea2827562 100644 --- a/cmd/vet/testdata/print.go +++ b/cmd/vet/testdata/print.go @@ -282,6 +282,6 @@ func (s recursiveStringer) String() string { type recursivePtrStringer int func (p *recursivePtrStringer) String() string { - fmt.Sprintf("%v", *p) // ERROR "arg \*p for printf causes recursive call to String method" + fmt.Sprintf("%v", *p) return fmt.Sprintln(p) // ERROR "arg p for print causes recursive call to String method" }