aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/modload/list.go
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2021-04-09 22:51:07 -0400
committerBryan C. Mills <bcmills@google.com>2021-04-30 18:06:26 +0000
commitc05d50f8f3b2f8a9ca66a6288168adf74d10586f (patch)
tree1b49ea0d744649045d171792dab55377c6dd2ee8 /src/cmd/go/internal/modload/list.go
parentee4f9656ac419bb92408f65f082c735a6b82d1fa (diff)
downloadgo-c05d50f8f3b2f8a9ca66a6288168adf74d10586f.tar.gz
go-c05d50f8f3b2f8a9ca66a6288168adf74d10586f.zip
cmd/go/internal/modload: avoid loading the module graph to list only the name of the main module
For #36460 For #29666 Change-Id: I9e46f7054d52c053be80c483757cdd34b22822d9 Reviewed-on: https://go-review.googlesource.com/c/go/+/309190 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@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.go12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/cmd/go/internal/modload/list.go b/src/cmd/go/internal/modload/list.go
index e33078b53c..66927a8288 100644
--- a/src/cmd/go/internal/modload/list.go
+++ b/src/cmd/go/internal/modload/list.go
@@ -78,6 +78,10 @@ func ListModules(ctx context.Context, args []string, mode ListMode) ([]*modinfo.
}
func listModules(ctx context.Context, rs *Requirements, args []string, mode ListMode) (_ *Requirements, mods []*modinfo.ModulePublic, mgErr error) {
+ if len(args) == 0 {
+ return rs, []*modinfo.ModulePublic{moduleInfo(ctx, rs, Target, mode)}, nil
+ }
+
var mg *ModuleGraph
if go117LazyTODO {
// Pull the args-loop below into another (new) loop.
@@ -90,10 +94,6 @@ func listModules(ctx context.Context, rs *Requirements, args []string, mode List
rs, mg, mgErr = expandGraph(ctx, rs)
}
- if len(args) == 0 {
- return rs, []*modinfo.ModulePublic{moduleInfo(ctx, rs, Target, mode)}, mgErr
- }
-
matchedModule := map[module.Version]bool{}
for _, arg := range args {
if strings.Contains(arg, `\`) {
@@ -149,10 +149,6 @@ func listModules(ctx context.Context, rs *Requirements, args []string, mode List
continue
}
- if go117LazyTODO {
- ModRoot() // Unversioned paths require that we be inside a module.
- }
-
// Module path or pattern.
var match func(string) bool
if arg == "all" {