...

Text file src/cmd/go/testdata/script/mod_list.txt

Documentation: cmd/go/testdata/script

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

View as plain text