-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Consider $GO
environment variable make precheck
checks
#20750
Conversation
For backports it's usually convenient to be able to set the $GO environment variable to the version used in the particular stable branch, e.g. on v1.10 we'd set GO=go1.16.15. However, that setting is currently not considered in contrib/scripts/check-fmt.sh. If there were changes in how gofmt formats code between Go versions and the system's Go version is newer than the $GO setting, using that gofmt binary might lead to check-fmt failure. Signed-off-by: Tobias Klauser <tobias@cilium.io>
For backports it's usually convenient to be able to set the $GO environment variable to the version used in the particular stable branch, e.g. on v1.10 we'd set GO=go1.16.15. However, that setting is currently not considered in tools/customvet. This can lead to unexpected failures such as the followin when running `GO=go1.16.15 make precheck` on v1.10 branch: contrib/scripts/custom-vet-check.sh main: internal error: package "sync" without types was imported from "github.com/cilium/cilium/pkg/cleanup" exit status 1 Signed-off-by: Tobias Klauser <tobias@cilium.io>
3585c8b
to
bc314ee
Compare
$GO
in check-fmt.sh
$GO
environment variable make precheck
checks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have $GOROOT
:/
@@ -3,13 +3,15 @@ | |||
set -e | |||
set -o pipefail | |||
|
|||
_goroot=$(${GO:-go} env GOROOT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty elegant.. hmm.
So far I got away without GOROOT, personally I find it's a bit opinionated and a pain to deal with.. maybe we could set the default for _goroot
to ""
iff $GO
is not set..?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, the Go toolchain will always return a non-empty value for "go env GOROOT", even if $GOROOT isn't set in the env. It'll derive it relative to the go binary invoked, unless it's overriden by some other means.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤯 I totally thought I ran this and got errors out, but now that I try it today it's fine. -ENO☕ I guess!
Me neither :) that's the beauty about "go env". |
For backports it's usually convenient to be able to set the
$GO
environment variable to the version used in the particular stable
branch, e.g. on v1.10 we'd set
GO=go1.16.15
. However, that setting iscurrently not considered in all check scripts invoked by
make precheck
.See individual commit messages for details.