github.com/megatontech/mynoteforgo@v0.0.0-20200507084910-5d0c6ea6e890/源码/cmd/go/testdata/script/mod_list.txt (about)

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