1 # Adding a tool upgrades the toolchain to 1.24.0 because older go
2 # versions fail to parse the tool directive. Issue #74739.
3 cp go.mod.go1.23.0 go.mod
4 go get -tool ./mytool
5 stderr 'go: upgraded go 1.23.0 => 1.24'
6 cmp go.mod go.mod.go1.24
7 go mod tidy
8 cmp go.mod go.mod.go1.24
9
10 # No toolchain change if go >= 1.24.0
11 cp go.mod.go1.24 go.mod
12 cmp go.mod go.mod.go1.24
13 go get -tool ./mytool
14 cmp go.mod go.mod.go1.24
15 go mod tidy
16 cmp go.mod go.mod.go1.24
17
18 # TODO(#78550): If #78550 is approved, go build should reject
19 # the go.mod file if go < 1.24 but there is a tool directive.
20 # For now, we will let it through.
21 cp go.mod.go1.23.0 go.mod
22 go list ./mytool
23 go build -n ./mytool
24
25 -- go.mod.go1.23.0 --
26 module m
27
28 go 1.23.0
29
30 tool m/mytool
31 -- go.mod.go1.24 --
32 module m
33
34 go 1.24
35
36 tool m/mytool
37 -- mytool/mytool.go --
38 package mytool
39
40 func main() {}
41
View as plain text