@@ -13,6 +13,7 @@ package main
13
13
14
14
import (
15
15
"fmt"
16
+ "go/version"
16
17
"os"
17
18
"path/filepath"
18
19
"regexp"
@@ -123,8 +124,6 @@ var tryDirs = []string{
123
124
"go1.22.6" ,
124
125
}
125
126
126
- var minBootStrapVersion [3 ]string = [3 ]string {"1" , "22" , "6" }
127
-
128
127
func bootstrapBuildTools () {
129
128
goroot_bootstrap := os .Getenv ("GOROOT_BOOTSTRAP" )
130
129
if goroot_bootstrap == "" {
@@ -139,16 +138,12 @@ func bootstrapBuildTools() {
139
138
140
139
// check bootstrap version.
141
140
ver := run (pathf ("%s/bin" , goroot_bootstrap ), CheckExit , pathf ("%s/bin/go" , goroot_bootstrap ), "version" )
142
- _ , after , _ := strings .Cut (ver , "go1" )
143
- if after != "" {
144
- v := strings .Split (after , "." )
145
- // if go version output is go1.22.6 goos/goarch
146
- // v is ["","22","6 goos/aoarch"].
147
- if len (v ) == 3 {
148
- if v [1 ] < minBootStrapVersion [1 ] || strings .Split (v [2 ], " " )[0 ] < minBootStrapVersion [2 ] {
149
- fatalf ("requires Go 1.%s.%s or later for bootstrap" , minBootStrapVersion [1 ], minBootStrapVersion [2 ])
150
- }
151
- }
141
+ // if go1.22.6,
142
+ // go version output go version 1.22.6 goos/aoarch,
143
+ // so split(ver," ")[2].
144
+ ver = strings .Split (ver , " " )[2 ]
145
+ if version .Compare (ver , tryDirs [1 ]) == - 1 {
146
+ fatalf ("requires %s or later for bootstrap" , tryDirs [1 ])
152
147
}
153
148
154
149
xprintf ("Building Go toolchain1 using %s.\n " , goroot_bootstrap )
0 commit comments