Skip to content
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

[release-1.8] ✨ Bump to Go 1.22.4 #3075

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
run:
timeout: 10m
go: "1.21"
go: "1.22"
skip-files:
- ".*zz_generated.*\\.go"
- "contrib/.*"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SHELL:=/usr/bin/env bash
#
# Go.
#
GO_VERSION ?= 1.21.11
GO_VERSION ?= 1.22.4
GO_CONTAINER_IMAGE ?= docker.io/library/golang:$(GO_VERSION)

# Use GOPROXY environment variable if set
Expand Down
27 changes: 16 additions & 11 deletions hack/ensure-go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ set -o errexit
set -o nounset
set -o pipefail

# MIN_GO_VERSION is the minimum, supported Go version.
# Note: Enforce only the minor version as we can't guarantee that
# the images we use in ProwJobs already use the latest patch version.
MIN_GO_VERSION="go${MIN_GO_VERSION:-1.21}"
if [[ "${TRACE-0}" == "1" ]]; then
set -o xtrace
fi

# shellcheck source=./hack/utils.sh
source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"

# Ensure the go tool exists and is a viable version.
verify_go_version() {
if ! command -v go >/dev/null 2>&1; then
if [[ -z "$(command -v go)" ]]; then
cat <<EOF
Can't find 'go' in PATH, please fix and retry.
See http://golang.org/doc/install for installation instructions.
Expand All @@ -34,19 +36,22 @@ EOF
fi

local go_version
IFS=" " read -ra go_version <<<"$(go version)"
if [ "${go_version[2]}" != 'devel' ] && \
[ "${MIN_GO_VERSION}" != "$(printf "%s\n%s" "${MIN_GO_VERSION}" "${go_version[2]}" | sort -s -t. -k 1,1 -k 2,2n -k 3,3n | head -n1)" ]; then
IFS=" " read -ra go_version <<< "$(go version)"
local minimum_go_version
minimum_go_version=go1.22
if [[ "${minimum_go_version}" != $(echo -e "${minimum_go_version}\n${go_version[2]}" | sort -s -t. -k 1,1 -k 2,2n -k 3,3n | head -n1) && "${go_version[2]}" != "devel" ]]; then
cat <<EOF
Detected go version: ${go_version[*]}.
Kubernetes requires ${MIN_GO_VERSION} or greater.
Please install ${MIN_GO_VERSION} or later.
Kubernetes requires ${minimum_go_version} or greater.
Please install ${minimum_go_version} or later.
EOF
return 2
fi
}


verify_go_version
verify_gopath_bin

# Explicitly opt into go modules.
# Explicitly opt into go modules, even though we're inside a GOPATH directory
export GO111MODULE=on
15 changes: 15 additions & 0 deletions hack/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,18 @@
get_root_path() {
git rev-parse --show-toplevel
}

# ensure GOPATH/bin is in PATH as we may install binaries to that directory in
# other ensure-* scripts, and expect them to be found in PATH later on
verify_gopath_bin() {
local gopath_bin

gopath_bin="$(go env GOPATH)/bin"
if ! printenv PATH | grep -q "${gopath_bin}"; then
cat <<EOF
error: \$GOPATH/bin=${gopath_bin} is not in your PATH.
See https://go.dev/doc/gopath_code for more instructions.
EOF
return 2
fi
}
Loading