summaryrefslogtreecommitdiffstats
path: root/src/cmd/go/testdata/script/mod_goline.txt
blob: 6b2eab0f2ed7dd232dfc2116051a511e83b3339a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
env TESTGO_VERSION=go1.99

! go list -f '{{.Module.GoVersion}}'
stderr 'go: updates to go.mod needed'
stderr 'go mod tidy'

go mod tidy
cat go.mod
go list -f '{{.Module.GoVersion}}'
stdout 1.22

# Adding a@v1.0.01 should upgrade to Go 1.23rc1.
cp go.mod go.mod1
go get example.com/a@v1.0.1
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$'
go list -f '{{.Module.GoVersion}}'
stdout 1.23rc1

# Repeating the update with go@1.24.0 should use that Go version.
cp go.mod1 go.mod
go get example.com/a@v1.0.1 go@1.24.0
go list -f '{{.Module.GoVersion}}'
stdout 1.24.0

# Go version-constrained updates should report the problems.
cp go.mod1 go.mod
! go get example.com/a@v1.0.2 go@1.24.2
stderr '^go: example.com/a@v1.0.2 requires go@1.25, not go@1.24.2$'
! go get example.com/a@v1.0.2 go@1.26.3
stderr '^go: example.com/a@v1.0.2 indirectly requires go@1.27, not go@1.26.3$'
go get example.com/a@v1.0.2 go@1.28rc1
go list -f '{{.Module.GoVersion}}'
stdout 1.28rc1
go get go@1.24.2
stderr '^go: downgraded go 1.28rc1 => 1.24.2$'
stderr '^go: downgraded example.com/a v1.0.2 => v1.0.1$'
stderr '^go: downgraded example.com/b v1.0.2 => v1.0.1$'
go list -f '{{.Module.GoVersion}}'
stdout 1.24.2

-- go.mod --
module m
go 1.21

require (
	example.com/a v1.0.0
	example.com/b v0.9.0
)

replace example.com/a v1.0.0 => ./a100
replace example.com/a v1.0.1 => ./a101
replace example.com/a v1.0.2 => ./a102
replace example.com/b v1.0.1 => ./b101
replace example.com/b v1.0.2 => ./b102
replace example.com/b v1.0.0 => ./b100
replace example.com/b v0.9.0 => ./b100

-- x.go --
package m

import (
	_ "example.com/a"
	_ "example.com/b"
)

-- a100/go.mod --
module example.com/a
go 1.22

require example.com/b v1.0.0

-- a100/a.go --
package a

-- a101/go.mod --
// this module is technically invalid, since the dep example.com/b has a newer go line than this module,
// but we should still be able to handle it.
module example.com/a
go 1.22

require example.com/b v1.0.1

-- a101/a.go --
package a

-- a102/go.mod --
// this module is technically invalid, since the dep example.com/b has a newer go line than this module,
// but we should still be able to handle it.
module example.com/a
go 1.25

require example.com/b v1.0.2

-- a102/a.go --
package a

-- b100/go.mod --
module example.com/b
go 1.22

-- b100/b.go --
package b

-- b101/go.mod --
module example.com/b
go 1.23rc1

-- b101/b.go --
package b

-- b102/go.mod --
module example.com/b
go 1.27

-- b102/b.go --
package b