Skip to content

Commit c24c448

Browse files
committed
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
1 parent ef819b2 commit c24c448

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ default: install
8181
# Create and update the vendor directory
8282
.PHONY: vendor
8383
vendor:
84-
go mod tidy -go $(GOVERSION)
84+
go mod tidy -go $(GOVERSION).0
8585
go mod vendor
8686

8787
.PHONY: vendorcheck

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/crc-org/crc/v2
22

3-
go 1.21
3+
go 1.21.0
44

55
require (
66
github.com/AlecAivazis/survey/v2 v2.3.7

tools/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/crc-org/crc/tools
22

3-
go 1.21
3+
go 1.21.0
44

55
require (
66
github.com/cfergeau/gomod2rpmdeps v0.0.0-20210223144124-2042c4850ca8

update-go-version.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ set -euo pipefail
99
golang_base_version=$1
1010
echo "Updating golang version to $golang_base_version"
1111

12-
go mod edit -go ${golang_base_version}
13-
go mod edit -go ${golang_base_version} tools/go.mod
12+
go mod edit -go "${golang_base_version}.0"
13+
go mod edit -go "${golang_base_version}.0" tools/go.mod
14+
1415
sed -i "s,^GOVERSION = 1.[0-9]\+,GOVERSION = ${golang_base_version}," Makefile
1516
sed -i "s,^\(FROM registry.ci.openshift.org/openshift/release:rhel-8-release-golang-\)1.[0-9]\+,\1${golang_base_version}," images/*/Dockerfile
1617
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

0 commit comments

Comments
 (0)