github.com/gagliardetto/golang-go@v0.0.0-20201020153340-53909ea70814/cmd/go/testdata/script/mod_download.txt (about) 1 env GO111MODULE=on 2 env GOPROXY=$GOPROXY/quiet 3 4 # download with version should print nothing 5 go mod download rsc.io/quote@v1.5.0 6 ! stdout . 7 ! stderr . 8 9 exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.info 10 exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.mod 11 exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.zip 12 13 # download of an invalid path should report the error 14 [short] skip 15 ! go mod download this.domain.is.invalid/somemodule@v1.0.0 16 stderr 'this.domain.is.invalid' 17 ! go mod download -json this.domain.is.invalid/somemodule@v1.0.0 18 stdout '"Error": ".*this.domain.is.invalid.*"' 19 20 # download -json with version should print JSON 21 go mod download -json 'rsc.io/quote@<=v1.5.0' 22 stdout '^\t"Path": "rsc.io/quote"' 23 stdout '^\t"Version": "v1.5.0"' 24 stdout '^\t"Info": ".*(\\\\|/)pkg(\\\\|/)mod(\\\\|/)cache(\\\\|/)download(\\\\|/)rsc.io(\\\\|/)quote(\\\\|/)@v(\\\\|/)v1.5.0.info"' 25 stdout '^\t"GoMod": ".*(\\\\|/)pkg(\\\\|/)mod(\\\\|/)cache(\\\\|/)download(\\\\|/)rsc.io(\\\\|/)quote(\\\\|/)@v(\\\\|/)v1.5.0.mod"' 26 stdout '^\t"Zip": ".*(\\\\|/)pkg(\\\\|/)mod(\\\\|/)cache(\\\\|/)download(\\\\|/)rsc.io(\\\\|/)quote(\\\\|/)@v(\\\\|/)v1.5.0.zip"' 27 stdout '^\t"Sum": "h1:6fJa6E\+wGadANKkUMlZ0DhXFpoKlslOQDCo259XtdIE="' # hash of testdata/mod version, not real version! 28 stdout '^\t"GoModSum": "h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe\+TKr0="' 29 ! stdout '"Error"' 30 31 # download queries above should not have added to go.mod. 32 go list -m all 33 ! stdout rsc.io 34 35 # add to go.mod so we can test non-query downloads 36 go mod edit -require rsc.io/quote@v1.5.2 37 ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.info 38 ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.mod 39 ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.zip 40 41 # module loading will page in the info and mod files 42 go list -m all 43 exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.info 44 exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.mod 45 ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.zip 46 47 # download will fetch and unpack the zip file 48 go mod download 49 exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.info 50 exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.mod 51 exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.zip 52 exists $GOPATH/pkg/mod/rsc.io/quote@v1.5.2 53 54 # download repopulates deleted files and directories independently. 55 rm $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.info 56 go mod download 57 exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.info 58 rm $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.mod 59 go mod download 60 exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.mod 61 rm $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.zip 62 go mod download 63 exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.zip 64 rm -r $GOPATH/pkg/mod/rsc.io/quote@v1.5.2 65 go mod download 66 exists $GOPATH/pkg/mod/rsc.io/quote@v1.5.2 67 68 # download reports the locations of downloaded files 69 go mod download -json 70 stdout '^\t"Path": "rsc.io/quote"' 71 stdout '^\t"Version": "v1.5.2"' 72 stdout '^\t"Info": ".*(\\\\|/)pkg(\\\\|/)mod(\\\\|/)cache(\\\\|/)download(\\\\|/)rsc.io(\\\\|/)quote(\\\\|/)@v(\\\\|/)v1.5.2.info"' 73 stdout '^\t"GoMod": ".*(\\\\|/)pkg(\\\\|/)mod(\\\\|/)cache(\\\\|/)download(\\\\|/)rsc.io(\\\\|/)quote(\\\\|/)@v(\\\\|/)v1.5.2.mod"' 74 stdout '^\t"Zip": ".*(\\\\|/)pkg(\\\\|/)mod(\\\\|/)cache(\\\\|/)download(\\\\|/)rsc.io(\\\\|/)quote(\\\\|/)@v(\\\\|/)v1.5.2.zip"' 75 stdout '^\t"Dir": ".*(\\\\|/)pkg(\\\\|/)mod(\\\\|/)rsc.io(\\\\|/)quote@v1.5.2"' 76 77 # download will follow replacements 78 go mod edit -require rsc.io/quote@v1.5.1 -replace rsc.io/quote@v1.5.1=rsc.io/quote@v1.5.3-pre1 79 go mod download 80 ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.1.zip 81 exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.3-pre1.zip 82 83 # download will not follow replacements for explicit module queries 84 go mod download -json rsc.io/quote@v1.5.1 85 exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.1.zip 86 87 # download reports errors encountered when locating modules 88 ! go mod download bad/path 89 stderr '^module bad/path: not a known dependency$' 90 ! go mod download bad/path@latest 91 stderr '^bad/path@latest: malformed module path "bad/path": missing dot in first path element$' 92 ! go mod download rsc.io/quote@v1.999.999 93 stderr '^rsc.io/quote@v1.999.999: reading .*/v1.999.999.info: 404 Not Found$' 94 ! go mod download -json bad/path 95 stdout '^\t"Error": "module bad/path: not a known dependency"' 96 97 # download main module returns an error 98 go mod download m 99 stderr '^go mod download: skipping argument m that resolves to the main module\n' 100 go mod download m@latest 101 stderr '^go mod download: skipping argument m@latest that resolves to the main module\n' 102 103 # allow go mod download without go.mod 104 env GO111MODULE=auto 105 rm go.mod 106 rm $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.2.1.zip 107 go mod download rsc.io/quote@v1.2.1 108 exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.2.1.zip 109 110 # download -x with version should print 111 # the underlying commands such as contacting GOPROXY. 112 go mod download -x rsc.io/quote@v1.0.0 113 ! stdout . 114 stderr 'get '$GOPROXY 115 116 -- go.mod -- 117 module m