@@ -13,14 +13,21 @@ import (
13
13
"github.com/hashicorp/go-version"
14
14
)
15
15
16
+ var v1_21 = version .Must (version .NewVersion ("1.21" ))
17
+
16
18
// installGoVersion installs given version of Go using Go
17
19
// according to https://golang.org/doc/manage-install
18
20
func (gb * GoBuild ) installGoVersion (ctx context.Context , v * version.Version ) (Go , error ) {
19
- versionString := v . Core () .String ()
21
+ goVersion := v .String ()
20
22
21
- // trim 0 patch versions as that's how Go does it :shrug:
22
- shortVersion := strings .TrimSuffix (versionString , ".0" )
23
- pkgURL := fmt .Sprintf ("golang.org/dl/go%s" , shortVersion )
23
+ // trim 0 patch versions as that's how Go does it
24
+ // for versions prior to 1.21
25
+ // See https://github.com/golang/go/issues/62136
26
+ if v .LessThan (v1_21 ) {
27
+ versionString := v .Core ().String ()
28
+ goVersion = strings .TrimSuffix (versionString , ".0" )
29
+ }
30
+ pkgURL := fmt .Sprintf ("golang.org/dl/go%s" , goVersion )
24
31
25
32
gb .log ().Printf ("go getting %q" , pkgURL )
26
33
cmd := exec .CommandContext (ctx , "go" , "get" , pkgURL )
@@ -36,7 +43,7 @@ func (gb *GoBuild) installGoVersion(ctx context.Context, v *version.Version) (Go
36
43
return Go {}, fmt .Errorf ("unable to install Go %s: %w\n %s" , v , err , out )
37
44
}
38
45
39
- cmdName := fmt .Sprintf ("go%s" , shortVersion )
46
+ cmdName := fmt .Sprintf ("go%s" , goVersion )
40
47
41
48
gb .log ().Printf ("downloading go %q" , v )
42
49
cmd = exec .CommandContext (ctx , cmdName , "download" )
0 commit comments