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

     1  # 'go list -mod=vendor -retracted' reports an error.
     2  go mod vendor
     3  ! go list -m -retracted -mod=vendor
     4  stderr '^go list -retracted cannot be used when vendoring is enabled$'
     5  rm vendor
     6  
     7  # 'go list -retracted' reports an error in GOPATH mode.
     8  env GO111MODULE=off
     9  ! go list -retracted
    10  stderr '^go list -retracted can only be used in module-aware mode$'
    11  env GO111MODULE=
    12  
    13  # 'go list pkg' does not show retraction.
    14  go list -f '{{with .Module}}{{with .Retracted}}retracted{{end}}{{end}}' example.com/retract
    15  ! stdout .
    16  
    17  # 'go list -retracted pkg' shows retraction.
    18  go list -retracted -f '{{with .Module}}{{with .Retracted}}retracted{{end}}{{end}}' example.com/retract
    19  stdout retracted
    20  
    21  # 'go list -m' does not show retraction.
    22  go list -m -f '{{with .Retracted}}retracted{{end}}' example.com/retract
    23  ! stdout .
    24  
    25  # 'go list -m -retracted' shows retraction.
    26  go list -m -retracted -f '{{with .Retracted}}retracted{{end}}' example.com/retract
    27  
    28  # 'go list -m mod@version' does not show retraction.
    29  go list -m -f '{{with .Retracted}}retracted{{end}}' example.com/retract@v1.0.0-unused
    30  ! stdout .
    31  
    32  # 'go list -m -retracted mod@version' does not show an error if the module
    33  # that would contain the retraction is unavailable. See #45305.
    34  go list -m -retracted -f '{{.Path}} {{.Version}} {{.Error}}' example.com/retract/missingmod@v1.0.0
    35  stdout '^example.com/retract/missingmod v1.0.0 <nil>$'
    36  exists $GOPATH/pkg/mod/cache/download/example.com/retract/missingmod/@v/v1.9.0.info
    37  ! exists $GOPATH/pkg/mod/cache/download/example.com/retract/missingmod/@v/v1.9.0.mod
    38  
    39  # 'go list -m -retracted mod@version' shows retractions.
    40  go list -m -retracted example.com/retract@v1.0.0-unused
    41  stdout '^example.com/retract v1.0.0-unused \(retracted\)$'
    42  go list -m -retracted -f '{{with .Retracted}}retracted{{end}}' example.com/retract@v1.0.0-unused
    43  stdout retracted
    44  
    45  # 'go list -m mod@latest' selects a previous release version, not self-retracted latest.
    46  go list -m -f '{{.Version}}{{with .Retracted}} retracted{{end}}' example.com/retract/self/prev@latest
    47  stdout '^v1.1.0$'
    48  
    49  # 'go list -m -retracted mod@latest' selects the self-retracted latest version.
    50  go list -m -retracted -f '{{.Version}}{{with .Retracted}} retracted{{end}}' example.com/retract/self/prev@latest
    51  stdout '^v1.9.0 retracted$'
    52  
    53  # 'go list -m mod@latest' selects a pre-release version if all release versions are retracted.
    54  go list -m -f '{{.Version}}{{with .Retracted}} retracted{{end}}' example.com/retract/self/prerelease@latest
    55  stdout '^v1.9.1-pre$'
    56  
    57  # 'go list -m -retracted mod@latest' selects the self-retracted latest version.
    58  go list -m -retracted -f '{{.Version}}{{with .Retracted}} retracted{{end}}' example.com/retract/self/prerelease@latest
    59  stdout '^v1.9.0 retracted$'
    60  
    61  # 'go list -m mod@latest' selects a pseudo-version if all versions are retracted.
    62  # TODO(golang.org/issue/24031): the proxy does not expose the pseudo-version,
    63  # even if all release versions are retracted.
    64  go list -m -e -f '{{.Error.Err}}' example.com/retract/self/pseudo@latest
    65  stdout '^module example.com/retract/self/pseudo: no matching versions for query "latest"$'
    66  
    67  # 'go list -m mod@latest' reports an error if all versions are retracted.
    68  go list -m -e -f '{{.Error.Err}}' example.com/retract/self/all@latest
    69  stdout '^module example.com/retract/self/all: no matching versions for query "latest"$'
    70  
    71  # 'go list -m mod@<v1.10' selects a previous release version, not self-retracted latest.
    72  # The @latest query is not special with respect to retractions.
    73  go list -m -f '{{.Version}}{{with .Retracted}} retracted{{end}}' example.com/retract/self/prev@<v1.10
    74  stdout '^v1.1.0$'
    75  
    76  # 'go list -m -versions' hides retracted versions.
    77  go list -m -versions example.com/retract
    78  stdout '^example.com/retract v1.0.0-good v1.1.0$'
    79  
    80  # 'go list -m -retracted -versions' shows retracted versions.
    81  go list -m -retracted -versions example.com/retract
    82  stdout '^example.com/retract v1.0.0-bad v1.0.0-good v1.0.0-unused v1.1.0$'
    83  
    84  # 'go list -m -u -versions' loads retractions and does not show retracted versions.
    85  go list -m -u -versions example.com/retract
    86  stdout '^example.com/retract v1.0.0-good v1.1.0$'
    87  go list -m -u -versions -f '{{with .Retracted}}retracted{{end}}' example.com/retract
    88  stdout retracted
    89  
    90  # 'go list -m -u' shows retraction.
    91  go list -m -u -f '{{with .Retracted}}retracted{{end}}' example.com/retract
    92  stdout retracted
    93  
    94  # 'go list -m -u' does not suggest an update to a self-retracted latest version.
    95  go list -m -u -f '{{with .Update}}{{.Version}}{{with .Retracted}} retracted{{end}}{{end}}' example.com/retract/self/prev@v1.0.0-bad
    96  stdout '^v1.1.0$'
    97  
    98  -- go.mod --
    99  module example.com/use
   100  
   101  go 1.15
   102  
   103  require example.com/retract v1.0.0-bad
   104  -- go.sum --
   105  example.com/retract v1.0.0-bad h1:liAW69rbtjY67x2CcNzat668L/w+YGgNX3lhJsWIJis=
   106  example.com/retract v1.0.0-bad/go.mod h1:0DvGGofJ9hr1q63cBrOY/jSY52OwhRGA0K47NE80I5Y=
   107  -- use.go --
   108  package use
   109  
   110  import _ "example.com/retract"
   111  

View as plain text