1 env TESTGO_VERSION=go1.99
2
3 ! go list -f '{{.Module.GoVersion}}'
4 stderr 'go: updates to go.mod needed'
5 stderr 'go mod tidy'
6
7 go mod tidy
8 cat go.mod
9 go list -f '{{.Module.GoVersion}}'
10 stdout 1.22
11
12 # Adding a@v1.0.01 should upgrade to Go 1.23rc1.
13 cp go.mod go.mod1
14 go get example.com/a@v1.0.1
15 stderr '^go: upgraded go 1.22 => 1.23rc1\ngo: upgraded example.com/a v1.0.0 => v1.0.1\ngo: upgraded example.com/b v1.0.0 => v1.0.1$'
16 go list -f '{{.Module.GoVersion}}'
17 stdout 1.23rc1
18
19 # Repeating the update with go@1.24.0 should use that Go version.
20 cp go.mod1 go.mod
21 go get example.com/a@v1.0.1 go@1.24.0
22 go list -f '{{.Module.GoVersion}}'
23 stdout 1.24.0
24
25 # Go version-constrained updates should report the problems.
26 cp go.mod1 go.mod
27 ! go get example.com/a@v1.0.2 go@1.24.2
28 stderr '^go: example.com/a@v1.0.2 requires go@1.25, not go@1.24.2$'
29 ! go get example.com/a@v1.0.2 go@1.26.3
30 stderr '^go: example.com/a@v1.0.2 indirectly requires go@1.27, not go@1.26.3$'
31 go get example.com/a@v1.0.2 go@1.28rc1
32 go list -f '{{.Module.GoVersion}}'
33 stdout 1.28rc1
34 go get go@1.24.2
35 stderr '^go: downgraded go 1.28rc1 => 1.24.2$'
36 stderr '^go: downgraded example.com/a v1.0.2 => v1.0.1$'
37 stderr '^go: downgraded example.com/b v1.0.2 => v1.0.1$'
38 go list -f '{{.Module.GoVersion}}'
39 stdout 1.24.2
40
41 -- go.mod --
42 module m
43 go 1.21
44
45 require (
46 example.com/a v1.0.0
47 example.com/b v0.9.0
48 )
49
50 replace example.com/a v1.0.0 => ./a100
51 replace example.com/a v1.0.1 => ./a101
52 replace example.com/a v1.0.2 => ./a102
53 replace example.com/b v1.0.1 => ./b101
54 replace example.com/b v1.0.2 => ./b102
55 replace example.com/b v1.0.0 => ./b100
56 replace example.com/b v0.9.0 => ./b100
57
58 -- x.go --
59 package m
60
61 import (
62 _ "example.com/a"
63 _ "example.com/b"
64 )
65
66 -- a100/go.mod --
67 module example.com/a
68 go 1.22
69
70 require example.com/b v1.0.0
71
72 -- a100/a.go --
73 package a
74
75 -- a101/go.mod --
76 // this module is technically invalid, since the dep example.com/b has a newer go line than this module,
77 // but we should still be able to handle it.
78 module example.com/a
79 go 1.22
80
81 require example.com/b v1.0.1
82
83 -- a101/a.go --
84 package a
85
86 -- a102/go.mod --
87 // this module is technically invalid, since the dep example.com/b has a newer go line than this module,
88 // but we should still be able to handle it.
89 module example.com/a
90 go 1.25
91
92 require example.com/b v1.0.2
93
94 -- a102/a.go --
95 package a
96
97 -- b100/go.mod --
98 module example.com/b
99 go 1.22
100
101 -- b100/b.go --
102 package b
103
104 -- b101/go.mod --
105 module example.com/b
106 go 1.23rc1
107
108 -- b101/b.go --
109 package b
110
111 -- b102/go.mod --
112 module example.com/b
113 go 1.27
114
115 -- b102/b.go --
116 package b
117
118
View as plain text