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

     1  env GO111MODULE=on
     2  [short] skip
     3  
     4  cd m
     5  
     6  # 'go list all' should list all of the packages used (directly or indirectly) by
     7  # the packages in the main module, but no other packages from the standard
     8  # library or active modules.
     9  #
    10  # 'go list ...' should list packages in all active modules and the standard library.
    11  #
    12  # 'go list example.com/m/...' should list packages in all modules that begin with 'example.com/m/'.
    13  #
    14  # 'go list ./...' should list only packages in the current module, not other active modules.
    15  #
    16  # Warnings about unmatched patterns should only be printed once.
    17  #
    18  # And the go command should be able to keep track of all this!
    19  go list -f '{{.ImportPath}}: {{.Match}}' all ... example.com/m/... ./... ./xyz...
    20  stdout 'example.com/m/useunicode: \[all \.\.\. example.com/m/... ./...\]'
    21  stdout 'example.com/m/useunsafe: \[all \.\.\. example.com/m/... ./...\]'
    22  [cgo] stdout 'example.com/m/useC: \[all \.\.\. example.com/m/... ./...\]'
    23  [!cgo] ! stdout example.com/m/useC
    24  stdout 'example.com/unused/useerrors: \[\.\.\.\]' # but not "all"
    25  stdout 'example.com/m/nested/useencoding: \[\.\.\. example.com/m/...\]' # but NOT "all" or "./..."
    26  stdout '^unicode: \[all \.\.\.\]'
    27  stdout '^unsafe: \[all \.\.\.\]'
    28  stdout 'index/suffixarray: \[\.\.\.\]'
    29  stdout 'cmd/pprof: \[\.\.\.\]'
    30  
    31  stderr -count=1 '^go: warning: "./xyz..." matched no packages$'
    32  
    33  # 'go list ./...' should not try to resolve the main module.
    34  cd ../empty
    35  go list -deps ./...
    36  ! stdout .
    37  ! stderr 'finding'
    38  stderr -count=1 '^go: warning: "./..." matched no packages'
    39  
    40  # disabling cgo should drop useC
    41  [short] skip
    42  env CGO_ENABLED=0
    43  go list -f '{{.ImportPath}}: {{.Match}}' all ... example.com/m/... ./... ./xyz...
    44  ! stdout example.com/m/useC
    45  
    46  -- m/go.mod --
    47  module example.com/m
    48  
    49  require example.com/unused v0.0.0 // indirect
    50  replace example.com/unused => ../unused
    51  
    52  require example.com/m/nested v0.0.0 // indirect
    53  replace example.com/m/nested => ../nested
    54  
    55  -- m/useC/useC.go --
    56  package useC
    57  import _ "C" // "C" is a pseudo-package, not an actual one
    58  -- m/useunicode/useunicode.go --
    59  package useunicode
    60  import _ "unicode"
    61  -- m/useunsafe/useunsafe.go --
    62  package useunsafe
    63  import _ "unsafe"
    64  
    65  -- unused/go.mod --
    66  module example.com/unused
    67  -- unused/useerrors/useerrors.go --
    68  package useerrors
    69  import _ "errors"
    70  
    71  -- nested/go.mod --
    72  module example.com/m/nested
    73  -- nested/useencoding/useencoding.go --
    74  package useencoding
    75  import _ "encoding"
    76  
    77  -- empty/go.mod --
    78  module example.com/empty
    79  

View as plain text