| 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 -mod=mod -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 -mod=mod -f '{{.Dir}}' rsc.io/quote |
| 11 |
stdout '.*mod[\\/]rsc.io[\\/][email protected]$' |
| 12 |
|
| 13 |
# downloaded dependencies are read-only |
| 14 |
exists -readonly $GOPATH/pkg/mod/rsc.io/[email protected] |
| 15 |
exists -readonly $GOPATH/pkg/mod/rsc.io/[email protected]/buggy |
| 16 |
|
| 17 |
# go clean -modcache can delete read-only dependencies |
| 18 |
go clean -modcache |
| 19 |
! exists $GOPATH/pkg/mod/rsc.io/[email protected] |
| 20 |
|
| 21 |
# list {{.Dir}} shows replaced directories |
| 22 |
cp go.mod2 go.mod |
| 23 |
go list -mod=mod -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[\\/][email protected]' |
| 26 |
stdout 'v1.3.0.*mod[\\/]rsc.io[\\/][email protected] .*[\\/]v1.3.1.mod => v1.3.1.*[email protected] .*[\\/]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 |
# even though it is only a test. |
| 34 |
go list -mod=mod rsc.io/quote/buggy |
| 35 |
|
| 36 |
# rsc.io/quote/buggy should not be listable as a module |
| 37 |
go list -m -e -f '{{.Error.Err}}' nonexist rsc.io/quote/buggy |
| 38 |
stdout '^module nonexist: not a known dependency$' |
| 39 |
stdout '^module rsc.io/quote/buggy: not a known dependency$' |
| 40 |
|
| 41 |
! go list -m nonexist rsc.io/quote/buggy |
| 42 |
stderr '^go: module nonexist: not a known dependency' |
| 43 |
stderr '^go: module rsc.io/quote/buggy: not a known dependency' |
| 44 |
|
| 45 |
# Module loader does not interfere with list -e (golang.org/issue/24149). |
| 46 |
go list -e -f '{{.Error.Err}}' database |
| 47 |
stdout 'package database is not in std' |
| 48 |
! go list database |
| 49 |
stderr 'package database is not in std' |
| 50 |
|
| 51 |
-- go.mod -- |
| 52 |
module x |
| 53 |
require rsc.io/quote v1.5.2 |
| 54 |
|
| 55 |
-- go.mod2 -- |
| 56 |
module x |
| 57 |
require rsc.io/quote v1.5.1 |
| 58 |
replace rsc.io/sampler v1.3.0 => rsc.io/sampler v1.3.1 |
| 59 |
|
| 60 |
-- x.go -- |
| 61 |
package x |
| 62 |
import _ "rsc.io/quote" |