aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/testdata/script/mod_get_replaced.txt
blob: d97f3f1a40117242fba478162505e0abb9d6eb97 (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
cp go.mod go.mod.orig

env oldGOPROXY=$GOPROXY

# If a wildcard replacement exists for an otherwise-nonexistent module,
# 'go get' should resolve it to the minimum valid pseudo-version.

go mod edit -replace=example.com/x=./x
go get -d example.com/x

go list -m example.com/x
stdout '^example.com/x v0.0.0-00010101000000-000000000000 '

# If specific-version replacements exist, the highest matching version should be used.
go mod edit -replace=example.com/x@v0.1.0=./x
go mod edit -replace=example.com/x@v0.2.0=./x

go get -d example.com/x
go list -m example.com/x
stdout '^example.com/x v0.2.0 '

go get -d example.com/x@<v0.2.0
go list -m example.com/x
stdout '^example.com/x v0.1.0 '


# The same should work with GOPROXY=off.

env GOPROXY=off
cp go.mod.orig go.mod

go mod edit -replace=example.com/x=./x
go get -d example.com/x

go list -m example.com/x
stdout '^example.com/x v0.0.0-00010101000000-000000000000 '

# If specific-version replacements exist, the highest matching version should be used.
go mod edit -replace=example.com/x@v0.1.0=./x
go mod edit -replace=example.com/x@v0.2.0=./x

go get -d example.com/x
go list -m example.com/x
stdout '^example.com/x v0.2.0 '

go get -d example.com/x@<v0.2.0
go list -m example.com/x
stdout '^example.com/x v0.1.0 '


# Replacements should also be listed as known versions, and 'go get' should sort
# them in with ordinary versions.

env GOPROXY=$oldGOPROXY

cp go.mod.orig go.mod
go list -versions -m rsc.io/quote
stdout 'v1.3.0 v1.4.0'

go get -d rsc.io/quote@v1.3
go list -m rsc.io/quote
stdout '^rsc.io/quote v1.3.0'

go mod edit -replace rsc.io/quote@v1.3.1=rsc.io/quote@v1.4.0

go list -versions -m rsc.io/quote
stdout 'v1.3.0 v1.3.1 v1.4.0'

go get -d rsc.io/quote@v1.3
go list -m rsc.io/quote
stdout '^rsc.io/quote v1.3.1 '

go get -d rsc.io/quote@>v1.3.1
go list -m rsc.io/quote
stdout '^rsc.io/quote v1.4.0'


# Replacements should allow 'go get' to work even with dotless module paths.

cp go.mod.orig go.mod

! go list example
stderr '^package example is not in GOROOT \(.*\)$'
! go get -d example
stderr '^go get: malformed module path "example": missing dot in first path element$'

go mod edit -replace example@v0.1.0=./example

! go list example
stderr '^module example provides package example and is replaced but not required; to add it:\n\tgo get example@v0.1.0$'

go get -d example
go list -m example
stdout '^example v0.1.0 '


-- go.mod --
module example.com

go 1.16
-- x/go.mod --
module example.com/x

go 1.16
-- x/x.go --
package x
-- example/go.mod --
module example
go 1.16
-- example/example.go --
package example