For some reason, including this directory in a staticcheck call causes it to drop all output: https://github.com/kubernetes/kubernetes/tree/master/staging/src/k8s.io/kubectl/pkg/cmd/edit/testdata
Steps to reproduce:
staticcheck -checks "all" ./vendor/k8s.io/kubectl/pkg/cmd/edit/testdata ./pkg/kubelet. Note the lack of output, and how quickly the program terminates.staticcheck -checks "all" ./pkg/kubelet, and observe the output issues.staticcheck -checks "all" ./vendor/k8s.io/kubectl/pkg/cmd/edit/testdata/record.go ./pkg/kubelet/kubelet.go. Note the lack of output, and how quickly the program terminates.staticcheck -checks "all" ./pkg/kubelet/kubelet.go, and observe the output issues.staticcheck -checks "all" k8s.io/kubernetes/vendor/k8s.io/kubectl/pkg/cmd/edit/testdata k8s.io/kubernetes/pkg/kubelet, and observe the output issuesstaticcheck -checks "all" k8s.io/kubernetes/pkg/kubelet, outputs the same issuesIncluding other packages in Kubernetes does not trigger this problem.
$ staticcheck -debug.version:
staticcheck (no version)
Compiled with Go version: go1.12.5
Built without Go modules
$ go version
go version go1.12.5 linux/amd64
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/usr/local/google/home/stclair/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/usr/local/google/home/stclair/go/k8s3"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/google/home/stclair/.gvm/gos/go1.12.5"
GOTMPDIR=""
GOTOOLDIR="/usr/local/google/home/stclair/.gvm/gos/go1.12.5/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build083108145=/tmp/go-build -gno-record-gcc-switches"
Version is built from honnef.co/go/tools => honnef.co/go/tools v0.0.1-2019.2.2
A quick first triage shows a combination of bugs in staticcheck (or possibly go/packages), possibly in Go, and user error.
The issue in staticcheck is that it seemingly terminates successfully upon receiving arguments that are invalid. That I will have to diagnose in depth.
As for invalid arguments, I observe the following:
go list ./vendor/k8s.io/kubectl/pkg/cmd/edit/testdata reports the following:unexpected directory layout:
import path: gopkg.in/yaml.v2
root: /home/dominikh/prj/src
dir: /home/dominikh/prj/src/k8s.io/kubernetes/vendor/gopkg.in/yaml.v2
expand root: /home/dominikh/prj/src
expand dir: /home/dominikh/prj/src/k8s.io/kubernetes/vendor/gopkg.in/yaml.v2
separator: /
This looks related to https://github.com/golang/go/issues/24854
Furthermore, go list k8s.io/kubernetes/vendor/k8s.io/kubectl/pkg/cmd/edit/testdata succeeds, which explains why that invocation of staticcheck works correctly, too.
go build forbids it: go build /tmp/foo.go /tmp/bar/foo.go
named files must all be in one directory; have /tmp/ and /tmp/bar/
Staticcheck, again, drops this error on the floor for some reason.
These are indeed all upstream issues. go/packages is not correctly reporting some of the errors that go list -e is (incorrectly) printing.
I'll leave this issue open until the issues have been addressed upstream.
golang/tools@597f57769402f90a9c238d64701717ff5fe472d6 should fix this issue. Note that I haven't yet updated the go.mod in this repository, though. I'll do that soon.
Most helpful comment
These are indeed all upstream issues. go/packages is not correctly reporting some of the errors that
go list -eis (incorrectly) printing.I'll leave this issue open until the issues have been addressed upstream.