aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/testdata/script/mod_replace_readonly.txt
blob: 882c755337a9180a1fbb64ca707c4af7b2b15ba9 (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
# Check that with -mod=readonly, when we load a package in a module that is
# replaced but not required, we emit an error with the command to add the
# requirement.
# Verifies golang.org/issue/41416, golang.org/issue/41577.
cp go.mod go.mod.orig

# Replace all versions of a module without requiring it.
# With -mod=mod, we'd add a requirement for a "zero" pseudo-version, but we
# can't in readonly mode, since its go.mod may alter the build list.
go mod edit -replace rsc.io/quote=./quote
! go list rsc.io/quote
stderr '^module rsc.io/quote provides package rsc.io/quote and is replaced but not required; try ''go get -d rsc.io/quote'' to add it$'
go get -d rsc.io/quote
cmp go.mod go.mod.latest
go list rsc.io/quote
cp go.mod.orig go.mod

# Same test with a specific version.
go mod edit -replace rsc.io/quote@v1.0.0-doesnotexist=./quote
! go list rsc.io/quote
stderr '^module rsc.io/quote provides package rsc.io/quote and is replaced but not required; try ''go get -d rsc.io/quote@v1.0.0-doesnotexist'' to add it$'
go get -d rsc.io/quote@v1.0.0-doesnotexist
cmp go.mod go.mod.specific
go list rsc.io/quote
cp go.mod.orig go.mod

# If there are multiple versions, the highest is suggested.
go mod edit -replace rsc.io/quote@v1.0.0-doesnotexist=./quote
go mod edit -replace rsc.io/quote@v1.1.0-doesnotexist=./quote
! go list rsc.io/quote
stderr '^module rsc.io/quote provides package rsc.io/quote and is replaced but not required; try ''go get -d rsc.io/quote@v1.1.0-doesnotexist'' to add it$'

-- go.mod --
module m

go 1.16
-- go.mod.latest --
module m

go 1.16

replace rsc.io/quote => ./quote

require rsc.io/quote v1.5.2 // indirect
-- go.mod.specific --
module m

go 1.16

replace rsc.io/quote v1.0.0-doesnotexist => ./quote

require rsc.io/quote v1.0.0-doesnotexist // indirect
-- use.go --
package use

import _ "rsc.io/quote"
-- quote/go.mod --
module rsc.io/quote

go 1.16
-- quote/quote.go --
package quote