-
Notifications
You must be signed in to change notification settings - Fork 130
Closed
Description
This is similar to #1349, but not quite the same:
load embedded ruleguard rules: rules/rules.go:13: can't load fmt
Kubernetes installs the required Go release with gimme inside the Kubernetes directory. With kubernetes/kubernetes#118996 that leads to _output/local/.gimme/versions/go1.21rc3.linux.amd64/bin
being in the PATH whenever go is invoked.
Kubernetes uses gocritic through golangci-lint and that is failing the same way, but the problem can also be reproduced with just the go-critic CLI, hence this issue here.
To reproduce with golangci-lint:
- check out [go] Bump images, dependencies and versions to go 1.21.0 kubernetes/kubernetes#118996
- ensure that some Go < 1.21 is in PATH, e.g. go-1.20.4
- run
hack/verify-golangci-lint.sh ./test/e2e
->
go version go1.21rc3 linux/amd64
installing golangci-lint and logcheck plugin from hack/tools into /nvme/gopath/src/k8s.io/kubernetes/_output/local/bin
running env LOGCHECK_CONFIG=/nvme/gopath/src/k8s.io/kubernetes/hack/logcheck.conf /nvme/gopath/src/k8s.io/kubernetes/_output/local/bin/golangci-lint run --config=/nvme/gopath/src/k8s.io/kubernetes/hack/golangci.yaml --color=always ./test/e2e
ERROR: level=warning msg="plugin: 'AnalyzerPlugin' plugins are deprecated, please use the new plugin signature: https://golangci-lint.run/contributing/new-linters/#create-a-plugin"
ERROR: level=error msg="[linters_context] gocritic: load embedded ruleguard rules: rules/rules.go:13: can't load fmt: setting an explicit GOROOT can fix this problem."
To reproduce with gocritic after installing Go as above:
$ rm $GOPATH/bin/gocritic
$ PATH=$(pwd)/_output/local/.gimme/versions/go1.21rc3.linux.amd64/bin:$PATH go version
go version go1.21rc3 linux/amd64
$ PATH=$(pwd)/_output/local/.gimme/versions/go1.21rc3.linux.amd64/bin:$PATH go install github.com/go-critic/go-critic/cmd/gocritic@latest
$ PATH=$(pwd)/_output/local/.gimme/versions/go1.21rc3.linux.amd64/bin:$PATH $GOPATH/bin/gocritic check ./test/e2e
panic: load embedded ruleguard rules: rules/rules.go:13: can't load fmt
goroutine 1 [running]:
main.main()
/nvme/gopath/pkg/mod/github.com/go-critic/go-critic@v0.8.2/cmd/gocritic/main.go:16 +0x48
This here uses Go 1.21rc3 outside of Kubernetes to build gocritic, which works:
$ go version
go version go1.21rc3 linux/amd64
$ go install github.com/go-critic/go-critic/cmd/gocritic@latest
$ PATH=$(pwd)/_output/local/.gimme/versions/go1.21rc3.linux.amd64/bin:$PATH $GOPATH/bin/gocritic check ./test/e2e
./test/e2e/e2e.go:313:9: wrapperFunc: use strings.ReplaceAll method in `strings.Replace(str, ";", "\n", -1)`
./test/e2e/e2e.go:312:10: wrapperFunc: use strings.ReplaceAll method in `strings.Replace(string(outputBytes), ",", "\n", -1)`
./test/e2e/e2e_test.go:161:5: sloppyLen: len(framework.TestContext.SpecSummaryOutput) <= 0 can be len(framework.TestContext.SpecSummaryOutput) == 0
schneiderfelipe
Metadata
Metadata
Assignees
Labels
No labels