summaryrefslogtreecommitdiffstats
path: root/src/cmd/go/testdata/script/mod_gomodcache.txt
blob: b2143e2093989719a2d000b12c415b5030a6c97e (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
# Test GOMODCACHE
env GO111MODULE=on

# Explicitly set GOMODCACHE
env GOMODCACHE=$WORK/modcache
go env GOMODCACHE
stdout $WORK[/\\]modcache
go get -d rsc.io/quote@v1.0.0
exists $WORK/modcache/cache/download/rsc.io/quote/@v/v1.0.0.info
grep '{"Version":"v1.0.0","Time":"2018-02-14T00:45:20Z"}' $WORK/modcache/cache/download/rsc.io/quote/@v/v1.0.0.info

# Ensure GOMODCACHE doesn't affect location of sumdb, but $GOMODCACHE/cache/download/sumdb is still written
exists $GOPATH/pkg/sumdb
! exists $WORK/modcache/sumdb
exists $WORK/modcache/cache/download/sumdb

# Test that the default GOMODCACHE is $GOPATH[0]/pkg/mod
env GOMODCACHE=
go env GOMODCACHE
stdout $GOPATH[/\\]pkg[/\\]mod
go get -d rsc.io/quote@v1.0.0
exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.0.0.info
grep '{"Version":"v1.0.0","Time":"2018-02-14T00:45:20Z"}' $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.0.0.info

# If neither GOMODCACHE or GOPATH are set, GOPATH defaults to the user's $HOME/go, so GOMODCACHE becomes $HOME/go/pkg/mod
[windows] env USERPROFILE=$WORK/home # Ensure USERPROFILE is a valid path (rather than /no-home/ so we don't run into the logic that "uninfers" GOPATH in cmd/go/main.go
[plan9] env home=$WORK/home
[!windows] [!plan9] env HOME=$WORK/home
env GOMODCACHE=
env GOPATH=
go env GOMODCACHE
stdout $HOME[/\\]go[/\\]pkg[/\\]mod

# If GOMODCACHE isn't set and GOPATH starts with the path list separator, it's an error.
env GOMODCACHE=
env GOPATH=${:}$WORK/this/is/ignored
! go env GOMODCACHE
stderr 'missing \$GOPATH'

# If GOMODCACHE isn't set and GOPATH has multiple elements only the first is used.
env GOMODCACHE=
env GOPATH=$WORK/first/path${:}$WORK/this/is/ignored
go env GOMODCACHE
stdout $WORK[/\\]first[/\\]path[/\\]pkg[/\\]mod

env GOMODCACHE=$WORK/modcache
go mod download rsc.io/quote@v1.0.0
exists $WORK/modcache/cache/download/rsc.io/quote/@v/v1.0.0.info

# Test that the following work even with GO111MODULE=off
env GO111MODULE=off

# Cleaning modcache
exists $WORK/modcache
env GOMODCACHE=$WORK/modcache
go clean -modcache
! exists $WORK/modcache

-- go.mod --
module m