1 # Test go mod download, why, and graph work in workspace mode.
2 # TODO(bcmills): clarify the interaction with #44435
3
4 go mod download rsc.io/quote
5 exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.info
6 exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.mod
7 exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.zip
8 ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.info
9 ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.mod
10 grep '^rsc\.io/quote v1\.5\.2/go\.mod h1:' go.work.sum
11 grep '^rsc\.io/quote v1\.5\.2 h1:' go.work.sum
12
13 go clean -modcache
14 rm go.work.sum
15 go mod download
16 exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.info
17 exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.mod
18 exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.zip
19 ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.info
20 ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.mod
21 grep '^rsc\.io/quote v1\.5\.2/go\.mod h1:' go.work.sum
22 grep '^rsc\.io/quote v1\.5\.2 h1:' go.work.sum
23
24 go mod why rsc.io/quote
25 stdout '# rsc.io/quote\nexample.com/a\nrsc.io/quote'
26
27 go mod graph
28 stdout 'example.com/a rsc.io/quote@v1.5.2\nexample.com/b example.com/c@v1.0.0\nrsc.io/quote@v1.5.2 rsc.io/sampler@v1.3.0\nrsc.io/sampler@v1.3.0 golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c'
29
30 -- go.work --
31 go 1.18
32
33 use (
34 ./a
35 ./b
36 )
37 -- a/go.mod --
38 go 1.18
39
40 module example.com/a
41
42 require "rsc.io/quote" v1.5.2
43 -- a/main.go --
44 package main
45
46 import (
47 "fmt"
48 "rsc.io/quote"
49 )
50
51 func main() {
52 fmt.Println(quote.Hello())
53 }
54 -- b/go.mod --
55 go 1.18
56
57 module example.com/b
58
59 require example.com/c v1.0.0
60 replace example.com/c => ../c
61 -- c/go.mod --
62 go 1.18
63
64 module example.com/c
65
66
View as plain text