diff options
author | Bryan C. Mills <bcmills@google.com> | 2020-09-17 16:24:29 -0400 |
---|---|---|
committer | Bryan C. Mills <bcmills@google.com> | 2020-09-22 16:52:00 +0000 |
commit | fd75989f46c80d2446dd9dcefaffbebdb7f7ea87 (patch) | |
tree | ff0ce203b50f1fc75c2be3a3bdee760e0cdb81b6 /src/cmd/go/internal/modload/buildlist.go | |
parent | d42b32e321fa5c5d2c93b2ad22d48e804c9f45d2 (diff) | |
download | go-fd75989f46c80d2446dd9dcefaffbebdb7f7ea87.tar.gz go-fd75989f46c80d2446dd9dcefaffbebdb7f7ea87.zip |
cmd/go/internal/modget: consolidate Load entrypoints
This change replaces ImportPaths, ImportPathsQuiet, LoadALL, and
LoadVendor with a single LoadPackages function, with a LoadOpts struct
that more clearly documents the variations in behavior.
It also eliminates the cmd/go/internal/load.ImportPaths function,
which was undocumented and had only one call site (within its own
package).
The modload.LoadTests global variable is subsumed by a field in the
new LoadOpts struct, and is no longer needed for callers that invoke
LoadPackages directly. It has been (temporarily) replaced with a
similar global variable, load.ModResolveTests, which can itself be
converted to an explicit, local argument.
For #37438
For #36460
Updates #40775
Fixes #26977
Change-Id: I4fb6086c01b04de829d98875db19cf0118d40f8c
Reviewed-on: https://go-review.googlesource.com/c/go/+/255938
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Diffstat (limited to 'src/cmd/go/internal/modload/buildlist.go')
-rw-r--r-- | src/cmd/go/internal/modload/buildlist.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/cmd/go/internal/modload/buildlist.go b/src/cmd/go/internal/modload/buildlist.go index 581a1b944a..059b020420 100644 --- a/src/cmd/go/internal/modload/buildlist.go +++ b/src/cmd/go/internal/modload/buildlist.go @@ -17,8 +17,8 @@ import ( ) // buildList is the list of modules to use for building packages. -// It is initialized by calling ImportPaths, ImportFromFiles, -// LoadALL, or LoadBuildList, each of which uses loaded.load. +// It is initialized by calling LoadPackages or ImportFromFiles, +// each of which uses loaded.load. // // Ideally, exactly ONE of those functions would be called, // and exactly once. Most of the time, that's true. @@ -31,8 +31,8 @@ var buildList []module.Version // module pattern, starting with the Target module and in a deterministic // (stable) order, without loading any packages. // -// Modules are loaded automatically (and lazily) in ImportPaths: -// LoadAllModules need only be called if ImportPaths is not, +// Modules are loaded automatically (and lazily) in LoadPackages: +// LoadAllModules need only be called if LoadPackages is not, // typically in commands that care about modules but no particular package. // // The caller must not modify the returned list. @@ -44,7 +44,7 @@ func LoadAllModules(ctx context.Context) []module.Version { } // LoadedModules returns the list of module requirements loaded or set by a -// previous call (typically LoadAllModules or ImportPaths), starting with the +// previous call (typically LoadAllModules or LoadPackages), starting with the // Target module and in a deterministic (stable) order. // // The caller must not modify the returned list. @@ -71,8 +71,8 @@ func ReloadBuildList() []module.Version { } // TidyBuildList trims the build list to the minimal requirements needed to -// retain the same versions of all packages from the preceding Load* or -// ImportPaths* call. +// retain the same versions of all packages from the preceding call to +// LoadPackages. func TidyBuildList() { used := map[module.Version]bool{Target: true} for _, pkg := range loaded.pkgs { |