From c24c44812e47fc2f1c825d9ed3e67734fd34bff9 Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Mon, 29 Jul 2024 16:40:04 +0530 Subject: [PATCH] update-go: Update script to get go major and minor version Starting in Go 1.21, Go toolchains will treat the go line in go.mod not as a guideline but as a rule, and the line can list specific point releases or release candidates. That is, Go 1.21.0 understands that it cannot even build code that says go 1.21.1 in its go.mod file, not to mention code that says much later versions like go 1.22.0. From go1.21 toolchain is enabled by default as auto mode and according to blog post[0], which means that if a module specify `go 1.21.0` in the mod file then other module requiring that module should have same minimum go rule. In case of image module it looks like they switched to using `go 1.21.0` instead of `go 1.21` in the mod file (for 5.32 tag release) and which stop us to using it as it is. ``` module m go 1.21.0 toolchain go1.21.4 This says that other modules requiring m need to provide at least Go 1.21.0, but when we are working in m itself, we want an even newer toolchain, at least Go 1.21.4 ``` In this PR we are going to update the script so that we can use `go1.N.P` version in mod file and `go1.N` for images and go runner. [0] https://go.dev/blog/toolchain --- Makefile | 2 +- go.mod | 2 +- tools/go.mod | 2 +- update-go-version.sh | 5 +++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 628fddada6..4967057364 100644 --- a/Makefile +++ b/Makefile @@ -81,7 +81,7 @@ default: install # Create and update the vendor directory .PHONY: vendor vendor: - go mod tidy -go $(GOVERSION) + go mod tidy -go $(GOVERSION).0 go mod vendor .PHONY: vendorcheck diff --git a/go.mod b/go.mod index 182c705656..f6b9677c5c 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/crc-org/crc/v2 -go 1.21 +go 1.21.0 require ( github.com/AlecAivazis/survey/v2 v2.3.7 diff --git a/tools/go.mod b/tools/go.mod index 255c1df733..564ff99ad5 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -1,6 +1,6 @@ module github.com/crc-org/crc/tools -go 1.21 +go 1.21.0 require ( github.com/cfergeau/gomod2rpmdeps v0.0.0-20210223144124-2042c4850ca8 diff --git a/update-go-version.sh b/update-go-version.sh index 4a046dc54d..14be9b8c10 100755 --- a/update-go-version.sh +++ b/update-go-version.sh @@ -9,8 +9,9 @@ set -euo pipefail golang_base_version=$1 echo "Updating golang version to $golang_base_version" -go mod edit -go ${golang_base_version} -go mod edit -go ${golang_base_version} tools/go.mod +go mod edit -go "${golang_base_version}.0" +go mod edit -go "${golang_base_version}.0" tools/go.mod + sed -i "s,^GOVERSION = 1.[0-9]\+,GOVERSION = ${golang_base_version}," Makefile sed -i "s,^\(FROM registry.ci.openshift.org/openshift/release:rhel-8-release-golang-\)1.[0-9]\+,\1${golang_base_version}," images/*/Dockerfile sed -i "s,^FROM registry.access.redhat.com/ubi8/go-toolset:[.0-9]\+,FROM registry.access.redhat.com/ubi8/go-toolset:${golang_base_version}," images/*/Dockerfile