Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/vet: Should warn against using %v print verb in Error() methods #33884

Open
mattayes opened this issue Aug 27, 2019 · 1 comment

Comments

@mattayes
Copy link

commented Aug 27, 2019

What version of Go are you using (go version)?

$ go version
go version go1.12.9 darwin/amd64

Does this issue reproduce with the latest release?

Yes (1.12.9 is the latest release).

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/mattayes/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/mattayes/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.9/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.9/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/10/46nlr7tj7z70cz9jyzdcntvr0000gn/T/go-build974633075=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I accidentally used the default printing verb (%v) in an Error() method on a struct, causing a stack overflow.

https://play.golang.org/p/P6Vpeg6-JDv

What did you expect to see?

I expected vet to catch the mistake and warn me about it, like it does when attempting to do this in a String() method.

https://play.golang.org/p/kw_-rXcc7iv

What did you see instead?

I received no warning and took down production 🙃.

@mattayes mattayes changed the title cmd/vet: Should warn against using %v print verb in Error() method cmd/vet: Should warn against using %v print verb in Error() methods Aug 27, 2019

@bcmills

This comment has been minimized.

Copy link
Member

commented Aug 27, 2019

@bcmills bcmills added this to the Go1.14 milestone Aug 27, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.