1 env TESTGO_VERSION=go1.21.0
2 env TESTGO_VERSION_SWITCH=switch
3
4 # If the main module's go.mod file lists a version lower than the version
5 # required by its dependencies, the commands that fetch and diagnose the module
6 # graph (such as 'go mod graph' and 'go mod verify') should fail explicitly:
7 # they can't interpret the graph themselves, and they aren't allowed to update
8 # the go.mod file to record a specific, stable toolchain version that can.
9
10 ! go mod verify
11 stderr '^go: rsc.io/future@v1.0.0: module rsc.io/future@v1.0.0 requires go >= 1.999 \(running go 1.21.0\)'
12
13 ! go mod graph
14 stderr '^go: rsc.io/future@v1.0.0: module rsc.io/future@v1.0.0 requires go >= 1.999 \(running go 1.21.0\)'
15
16 # TODO(#64008): 'go mod download' without arguments should fail too.
17
18
19 # 'go get' should update the main module's go.mod file to a version compatible with the
20 # go version required for rsc.io/future, not fail.
21 go get .
22 stderr '^go: module rsc.io/future@v1.0.0 requires go >= 1.999; switching to go1.999testmod$'
23 stderr '^go: upgraded go 1.21 => 1.999$'
24 stderr '^go: added toolchain go1.999testmod$'
25
26
27 # Now, the various 'go mod' subcommands should succeed.
28
29 go mod download
30
31 go mod verify
32
33 go mod graph
34
35
36 -- go.mod --
37 module example
38
39 go 1.21
40
41 require rsc.io/future v1.0.0
42 -- example.go --
43 package example
44
45 import _ "rsc.io/future"
46
View as plain text