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

     1  env GO111MODULE=on
     2  [short] skip
     3  
     4  # Populate go.sum.
     5  go mod tidy
     6  cp go.mod go.mod.orig
     7  
     8  go list -test all
     9  stdout rsc.io/quote
    10  stdout golang.org/x/text/language
    11  
    12  # why a package?
    13  go mod why golang.org/x/text/language
    14  cmp stdout why-language.txt
    15  
    16  # why a module?
    17  go mod why -m golang.org...
    18  cmp stdout why-text-module.txt
    19  
    20  # why a package used only in tests?
    21  go mod why rsc.io/testonly
    22  cmp stdout why-testonly.txt
    23  
    24  # why a module used only in a test of a dependency?
    25  go mod why -m rsc.io/testonly
    26  cmp stdout why-testonly.txt
    27  
    28  # test package not needed
    29  go mod why golang.org/x/text/unused
    30  cmp stdout why-unused.txt
    31  
    32  # vendor doesn't use packages used only in tests.
    33  go mod why -vendor rsc.io/testonly
    34  cmp stdout why-vendor.txt
    35  
    36  # vendor doesn't use modules used only in tests.
    37  go mod why -vendor -m rsc.io/testonly
    38  cmp stdout why-vendor-module.txt
    39  
    40  # test multiple packages
    41  go mod why golang.org/x/text/language golang.org/x/text/unused
    42  cmp stdout why-both.txt
    43  
    44  # test multiple modules
    45  go mod why -m rsc.io/quote rsc.io/sampler
    46  cmp stdout why-both-module.txt
    47  
    48  # package in a module that isn't even in the module graph
    49  # (https://golang.org/issue/26977)
    50  go mod why rsc.io/fortune
    51  cmp stdout why-missing.txt
    52  
    53  # None of these command should have changed the go.mod file.
    54  cmp go.mod go.mod.orig
    55  
    56  -- go.mod --
    57  module mymodule
    58  require rsc.io/quote v1.5.2
    59  
    60  -- x/x.go --
    61  package x
    62  import _ "mymodule/z"
    63  
    64  -- y/y.go --
    65  package y
    66  
    67  -- y/y_test.go --
    68  package y
    69  import _ "rsc.io/quote"
    70  
    71  -- z/z.go --
    72  package z
    73  import _ "mymodule/y"
    74  
    75  
    76  -- why-language.txt --
    77  # golang.org/x/text/language
    78  mymodule/y
    79  mymodule/y.test
    80  rsc.io/quote
    81  rsc.io/sampler
    82  golang.org/x/text/language
    83  -- why-unused.txt --
    84  # golang.org/x/text/unused
    85  (main module does not need package golang.org/x/text/unused)
    86  -- why-text-module.txt --
    87  # golang.org/x/text
    88  mymodule/y
    89  mymodule/y.test
    90  rsc.io/quote
    91  rsc.io/sampler
    92  golang.org/x/text/language
    93  -- why-testonly.txt --
    94  # rsc.io/testonly
    95  mymodule/y
    96  mymodule/y.test
    97  rsc.io/quote
    98  rsc.io/sampler
    99  rsc.io/sampler.test
   100  rsc.io/testonly
   101  -- why-vendor.txt --
   102  # rsc.io/testonly
   103  (main module does not need to vendor package rsc.io/testonly)
   104  -- why-vendor-module.txt --
   105  # rsc.io/testonly
   106  (main module does not need to vendor module rsc.io/testonly)
   107  -- why-both.txt --
   108  # golang.org/x/text/language
   109  mymodule/y
   110  mymodule/y.test
   111  rsc.io/quote
   112  rsc.io/sampler
   113  golang.org/x/text/language
   114  
   115  # golang.org/x/text/unused
   116  (main module does not need package golang.org/x/text/unused)
   117  -- why-both-module.txt --
   118  # rsc.io/quote
   119  mymodule/y
   120  mymodule/y.test
   121  rsc.io/quote
   122  
   123  # rsc.io/sampler
   124  mymodule/y
   125  mymodule/y.test
   126  rsc.io/quote
   127  rsc.io/sampler
   128  -- why-missing.txt --
   129  # rsc.io/fortune
   130  (main module does not need package rsc.io/fortune)
   131  

View as plain text