aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/modload/list.go
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2021-02-26 17:40:18 -0500
committerBryan C. Mills <bcmills@google.com>2021-03-02 20:29:03 +0000
commit2a2f99eefb70a66ecb9560a61b5cf23a5ca02ecb (patch)
tree38ad7288a609da0ca3ff4fb7e8569a1dd98966f6 /src/cmd/go/internal/modload/list.go
parentb65091c11d711ff3b01cd25393305410e1b0b377 (diff)
downloadgo-2a2f99eefb70a66ecb9560a61b5cf23a5ca02ecb.tar.gz
go-2a2f99eefb70a66ecb9560a61b5cf23a5ca02ecb.zip
cmd/go/internal/modload: do not resolve an arbitrary version for 'go list --versions'
If we don't actually require the listed module, we previously implicitly resolved "latest", but also (erroneously) forgot to apply exclusions and retractions for it. But there is really no need to resolve "latest" in this case at all — now we omit the version from the reported module info entirely. Fixes #44296 Change-Id: Id595f52f597c7213bd65b73bf066a678d9e1d694 Reviewed-on: https://go-review.googlesource.com/c/go/+/297150 Trust: Bryan C. Mills <bcmills@google.com> Reviewed-by: Michael Matloob <matloob@golang.org>
Diffstat (limited to 'src/cmd/go/internal/modload/list.go')
-rw-r--r--src/cmd/go/internal/modload/list.go14
1 files changed, 3 insertions, 11 deletions
diff --git a/src/cmd/go/internal/modload/list.go b/src/cmd/go/internal/modload/list.go
index 3491f941cd..de16c2f786 100644
--- a/src/cmd/go/internal/modload/list.go
+++ b/src/cmd/go/internal/modload/list.go
@@ -136,17 +136,9 @@ func listModules(ctx context.Context, args []string, listVersions, listRetracted
if listVersions {
// Don't make the user provide an explicit '@latest' when they're
// explicitly asking what the available versions are.
- // Instead, resolve the module, even if it isn't an existing dependency.
- info, err := Query(ctx, arg, "latest", "", nil)
- if err == nil {
- mod := moduleInfo(ctx, module.Version{Path: arg, Version: info.Version}, false, listRetracted)
- mods = append(mods, mod)
- } else {
- mods = append(mods, &modinfo.ModulePublic{
- Path: arg,
- Error: modinfoError(arg, "", err),
- })
- }
+ // Instead, return a modinfo without a version,
+ // to which we can attach the requested version list.
+ mods = append(mods, &modinfo.ModulePublic{Path: arg})
continue
}
if cfg.BuildMod == "vendor" {