...

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

Documentation: cmd/go/testdata/script

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

View as plain text