1 env GO111MODULE=on
2
3 # Before vendoring, we expect to see the original directory.
4 go list -f '{{with .Module}}{{.Version}}{{end}} {{.Dir}}' rsc.io/quote/v3
5 stdout 'v3.0.0'
6 stdout '.*[/\\]not-rsc.io[/\\]quote[/\\]v3'
7
8 # Since all dependencies are replaced, 'go mod vendor' should not
9 # have to download anything from the network.
10 go mod vendor
11 ! stderr 'downloading'
12 ! stderr 'finding'
13
14 # After vendoring, we expect to see the replacement in the vendor directory,
15 # without attempting to look up the non-replaced version.
16 cmp vendor/rsc.io/quote/v3/quote.go local/not-rsc.io/quote/v3/quote.go
17
18 go list -mod=vendor -f '{{with .Module}}{{.Version}}{{end}} {{.Dir}}' rsc.io/quote/v3
19 stdout 'v3.0.0'
20 stdout '.*[/\\]vendor[/\\]rsc.io[/\\]quote[/\\]v3'
21 ! stderr 'finding'
22 ! stderr 'lookup disabled'
23
24 # 'go list' should provide the original replacement directory as the module's
25 # replacement path.
26 go list -mod=vendor -f '{{with .Module}}{{with .Replace}}{{.Path}}{{end}}{{end}}' rsc.io/quote/v3
27 stdout '.*[/\\]not-rsc.io[/\\]quote[/\\]v3'
28
29 # The same module can't be used as two different paths.
30 cd multiple-paths
31 ! go mod vendor
32 stderr 'rsc.io/quote/v3@v3.0.0 used for two different module paths \(not-rsc.io/quote/v3 and rsc.io/quote/v3\)'
33
34 -- go.mod --
35 module example.com/replace
36
37 require rsc.io/quote/v3 v3.0.0
38 replace rsc.io/quote/v3 => ./local/not-rsc.io/quote/v3
39 -- imports.go --
40 package replace
41
42 import _ "rsc.io/quote/v3"
43
44 -- local/not-rsc.io/quote/v3/go.mod --
45 module not-rsc.io/quote/v3
46
47 -- local/not-rsc.io/quote/v3/quote.go --
48 package quote
49
50 -- multiple-paths/main.go --
51 package main
52 import (
53 "fmt"
54 "rsc.io/quote/v3"
55 )
56 func main() {
57 fmt.Println(quote.GoV3())
58 }
59 -- multiple-paths/go.mod --
60 module quoter
61 require (
62 rsc.io/quote/v3 v3.0.0
63 not-rsc.io/quote/v3 v3.0.0
64 )
65 replace not-rsc.io/quote/v3 => rsc.io/quote/v3 v3.0.0
66 -- multiple-paths/go.sum --
67 golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
68 rsc.io/quote/v3 v3.0.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
69 rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
70
View as plain text