github.com/gagliardetto/golang-go@v0.0.0-20201020153340-53909ea70814/cmd/go/testdata/script/mod_list.txt (about) 1 env GO111MODULE=on 2 [short] skip 3 4 # list {{.Dir}} shows main module and go.mod but not not-yet-downloaded dependency dir. 5 go list -m -f '{{.Path}} {{.Main}} {{.GoMod}} {{.Dir}}' all 6 stdout '^x true .*[\\/]src[\\/]go.mod .*[\\/]src$' 7 stdout '^rsc.io/quote false .*[\\/]v1.5.2.mod $' 8 9 # list {{.Dir}} shows dependency after download (and go list without -m downloads it) 10 go list -f '{{.Dir}}' rsc.io/quote 11 stdout '.*mod[\\/]rsc.io[\\/]quote@v1.5.2$' 12 13 # downloaded dependencies are read-only 14 exists -readonly $GOPATH/pkg/mod/rsc.io/quote@v1.5.2 15 exists -readonly $GOPATH/pkg/mod/rsc.io/quote@v1.5.2/buggy 16 17 # go clean -modcache can delete read-only dependencies 18 go clean -modcache 19 ! exists $GOPATH/pkg/mod/rsc.io/quote@v1.5.2 20 21 # list {{.Dir}} shows replaced directories 22 cp go.mod2 go.mod 23 go list -f {{.Dir}} rsc.io/quote 24 go list -m -f '{{.Path}} {{.Version}} {{.Dir}}{{with .Replace}} {{.GoMod}} => {{.Version}} {{.Dir}} {{.GoMod}}{{end}}' all 25 stdout 'mod[\\/]rsc.io[\\/]quote@v1.5.1' 26 stdout 'v1.3.0.*mod[\\/]rsc.io[\\/]sampler@v1.3.1 .*[\\/]v1.3.1.mod => v1.3.1.*sampler@v1.3.1 .*[\\/]v1.3.1.mod' 27 28 # list std should work 29 go list std 30 stdout ^math/big 31 32 # rsc.io/quote/buggy should be listable as a package 33 go list rsc.io/quote/buggy 34 35 # rsc.io/quote/buggy should not be listable as a module 36 go list -m -e -f '{{.Error.Err}}' nonexist rsc.io/quote/buggy 37 stdout '^module nonexist: not a known dependency$' 38 stdout '^module rsc.io/quote/buggy: not a known dependency$' 39 40 ! go list -m nonexist rsc.io/quote/buggy 41 stderr '^go list -m: module nonexist: not a known dependency' 42 stderr '^go list -m: module rsc.io/quote/buggy: not a known dependency' 43 44 # Module loader does not interfere with list -e (golang.org/issue/24149). 45 go list -e -f '{{.Error.Err}}' database 46 stdout 'no Go files in ' 47 ! go list database 48 stderr 'no Go files in ' 49 50 -- go.mod -- 51 module x 52 require rsc.io/quote v1.5.2 53 54 -- go.mod2 -- 55 module x 56 require rsc.io/quote v1.5.1 57 replace rsc.io/sampler v1.3.0 => rsc.io/sampler v1.3.1 58 59 -- x.go -- 60 package x 61 import _ "rsc.io/quote"