mirror of
https://github.com/golang/go
synced 2024-11-11 22:20:22 -07:00
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>
This commit is contained in:
parent
ee4f9656ac
commit
c05d50f8f3
@ -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" {
|
||||
|
@ -22,7 +22,7 @@ cmp go.mod go.mod.orig
|
||||
|
||||
# Update manually. Listing modules should produce an error.
|
||||
go mod edit -require=example.com/badchain/a@v1.1.0
|
||||
! go list -m
|
||||
! go list -m all
|
||||
cmp stderr list-expected
|
||||
|
||||
# Try listing a package that imports a package
|
||||
|
Loading…
Reference in New Issue
Block a user