Skip to content

Commit

Permalink
Merge pull request #3074 from sbueringer/pr-1.10-go-1.22.4
Browse files Browse the repository at this point in the history
[release-1.10] ✨ Bump to Go 1.22.4
  • Loading branch information
k8s-ci-robot authored Jun 28, 2024
2 parents 50276e2 + aace73e commit eb41588
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 13 deletions.
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$"
- "_conversion\\.go$"
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
}

0 comments on commit eb41588

Please sign in to comment.