Go-tools: Problems when running staticcheck concurrently

Created on 28 Jun 2019  路  6Comments  路  Source: dominikh/go-tools

The output of 'staticcheck -version'

staticcheck (no version)

Not sure why it's displaying no version. I go get'd it.

The output of 'staticcheck -debug.version' (it is fine if this command fails)

staticcheck (no version)

Compiled with Go version: go1.11.1

The output of 'go version'

go version go1.12.6 darwin/amd64

The output of 'go env'

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/bartek/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/bartek/gocode"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/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/zv/kh35w1j12wn5_4md98dl9zfr0000gn/T/go-build521415572=/tmp/go-build -gno-record-gcc-switches -fno-common"

Exactly which command you ran

In github.com/stellar/go:

ls -d */ \
  | egrep -v '^vendor|^docs' \
  | xargs -I {} -P 4 staticcheck -tests=false -checks="all,-ST1003,-SA1019,-ST1005,-ST1000,-ST1016" ./{}...

Output of the command and what's wrong with the output

-: could not analyze dependency github.com/stellar/go/support/errors of github.com/stellar/go/address: 
    could not analyze dependency github.com/stellar/go/vendor/github.com/pkg/errors of github.com/stellar/go/support/errors: 
    could not analyze dependency fmt of github.com/stellar/go/vendor/github.com/pkg/errors: 
    could not analyze dependency os of fmt: 
    could not analyze dependency time of os: 
    could not load export data: no export data for "time" (compile)

Similar error in CI here.

Where we can read the code you're running staticcheck on

github.com/stellar/go

Additional info

It seems that the problem occurs in the first execution of staticcheck when it's started concurrently (-P 4 option in xargs). All the following executions work correctly. If the first execution of the script is without -P 4 param it also works.

bug upstream

All 6 comments

Will look into it.

In the meantime, do note that staticcheck already parallelizes work, and likely does so more efficiently than you could hope to achieve by running multiple instances of it. A simple staticcheck ./... should suffice.

Upstream has fixed the issue on their end, and we backported their patches to our copy of the caching code. The next release of staticcheck coupled with the next release of Go should no longer encounter this problem.

I got a whole bunch of these kinds of messages today, with [email protected]+ and Go 1.14.2.

I run staticcheck by hack/verify-staticcheck.sh script.
I noticed maybe this caused by kubernetes using too old version of staticcheck (v0.0.1-2019.2.2).

https://github.com/kubernetes/kubernetes/blob/66e3c66eafdcecc49c20f21953b2b069fc17f645/hack/tools/go.mod#L13

I tried update staticcheck version to v0.0.1-2020.1.3, but I got 3 confused message about SA1019, such as follows:

vendor/k8s.io/apimachinery/pkg/api/apitesting/roundtrip/roundtrip.go:28:2: package github.com/golang/protobuf/proto is deprecated: Use the "google.golang.org/protobuf/proto" package instead.  (SA1019)

I've checked https://staticcheck.io/docs/checks#SA1019, but still don't know why staticcheck reports github.com/golang/protobuf/proto is deprecated.

@dominikh Could you please take an eye on it?

I noticed maybe this caused by kubernetes using too old version of staticcheck (v0.0.1-2019.2.2).

Yes, you need to use at least 2020.1 to avoid that bug.

I've checked https://staticcheck.io/docs/checks#SA1019, but still don't know why staticcheck reports github.com/golang/protobuf/proto is deprecated.

Because it _is_ deprecated: https://github.com/golang/protobuf/blob/fa093f59480c0adaaabf88a72a0b0e48b95aec25/proto/proto.go#L12

Got it, thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dominikh picture dominikh  路  3Comments

dominikh picture dominikh  路  4Comments

dominikh picture dominikh  路  3Comments

tamird picture tamird  路  3Comments

igungor picture igungor  路  3Comments