From e487ea84218d5095b6ff05ef1de6d44fc9b64183 Mon Sep 17 00:00:00 2001 From: Shenghou Ma Date: Fri, 18 Jan 2013 02:24:12 +0800 Subject: [PATCH] cmd/vet: don't complain about Error() Fixes #4598. R=golang-dev, dsymonds, r CC=golang-dev https://golang.org/cl/7102050 --- src/cmd/vet/print.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cmd/vet/print.go b/src/cmd/vet/print.go index cda5fcd7c8..a402d3de41 100644 --- a/src/cmd/vet/print.go +++ b/src/cmd/vet/print.go @@ -253,7 +253,8 @@ func (f *File) checkPrint(call *ast.CallExpr, name string, skip int) { } } if len(args) <= skip { - if *verbose && !isLn { + // TODO: check that the receiver of Error() is of type error. + if !isLn && name != "Error" { f.Badf(call.Pos(), "no args in %s call", name) } return @@ -299,6 +300,8 @@ func BadFunctionUsedInTests() { f.Warnf(0, "%s", "hello", 3) // ERROR "wrong number of args in Warnf call" f.Warnf(0, "%r", "hello") // ERROR "unrecognized printf verb" f.Warnf(0, "%#s", "hello") // ERROR "unrecognized printf flag" + var e error + fmt.Println(e.Error()) // correct, used to trigger "no args in Error call" } // printf is used by the test. -- 2.48.1