Closed
Description
What version of Go are you using (go version
)?
$ go version
go version go1.9.1 darwin/amd64
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (go env
)?
MacOS Seirra.
$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/vhosakot/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.9.1/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.9.1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/83/1jxkgzw91vg810dqdlvqg9x80000gn/T/go-build352630876=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
What did you do?
Ran go tool vet
on the following code that has an unconditional return
inside a for
loop:
func test() error {
for i := 0; i < 10; i++ {
return nil
}
return nil
}
What did you expect to see?
An error or a warning that the loop exits unconditionally after just one iteration similar to the error SA4004 The loop exits unconditionally after one iteration
in the Go staticcheck
tool in https://staticcheck.io/docs/staticcheck.
What did you see instead?
No error or warning.