aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/modload/import.go
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2020-09-18 16:14:08 -0400
committerBryan C. Mills <bcmills@google.com>2020-09-22 20:45:27 +0000
commit8f8a8e8921eb46ffba9a5400a259e21eb2011bb7 (patch)
treefc433302f0e6a57802ce332d33553423e611bc72 /src/cmd/go/internal/modload/import.go
parentd140c357442471ca0d56615811fb4226e99fadd5 (diff)
downloadgo-8f8a8e8921eb46ffba9a5400a259e21eb2011bb7.tar.gz
go-8f8a8e8921eb46ffba9a5400a259e21eb2011bb7.zip
cmd/go/internal/modload: eliminate QueryPackage
QueryPackage was a wrapper around QueryPattern with extra validation, called only once from within the same package. Most of that validation was already performed much earlier, in (*loader).Load. Inline the remaining validation and remove the needless indirection. For #36460 Change-Id: I108a01d416197db8f886889554e07b29f0c37f3f Reviewed-on: https://go-review.googlesource.com/c/go/+/256057 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/import.go')
-rw-r--r--src/cmd/go/internal/modload/import.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/cmd/go/internal/modload/import.go b/src/cmd/go/internal/modload/import.go
index e93eebcb81..c36c8bd29b 100644
--- a/src/cmd/go/internal/modload/import.go
+++ b/src/cmd/go/internal/modload/import.go
@@ -261,7 +261,7 @@ func queryImport(ctx context.Context, path string) (module.Version, error) {
}
// Every module path in mods is a prefix of the import path.
- // As in QueryPackage, prefer the longest prefix that satisfies the import.
+ // As in QueryPattern, prefer the longest prefix that satisfies the import.
sort.Slice(mods, func(i, j int) bool {
return len(mods[i].Path) > len(mods[j].Path)
})
@@ -300,9 +300,9 @@ func queryImport(ctx context.Context, path string) (module.Version, error) {
// in the build list, and isn't in any other module that the user has
// shimmed in via a "replace" directive.
// Moreover, the import path is reserved for the standard library, so
- // QueryPackage cannot possibly find a module containing this package.
+ // QueryPattern cannot possibly find a module containing this package.
//
- // Instead of trying QueryPackage, report an ImportMissingError immediately.
+ // Instead of trying QueryPattern, report an ImportMissingError immediately.
return module.Version{}, &ImportMissingError{Path: path}
}
@@ -321,11 +321,11 @@ func queryImport(ctx context.Context, path string) (module.Version, error) {
// and return m, dir, ImpportMissingError.
fmt.Fprintf(os.Stderr, "go: finding module for package %s\n", path)
- candidates, err := QueryPackage(ctx, path, "latest", CheckAllowed)
+ candidates, err := QueryPattern(ctx, path, "latest", CheckAllowed)
if err != nil {
if errors.Is(err, os.ErrNotExist) {
// Return "cannot find module providing package […]" instead of whatever
- // low-level error QueryPackage produced.
+ // low-level error QueryPattern produced.
return module.Version{}, &ImportMissingError{Path: path, QueryErr: err}
} else {
return module.Version{}, err
@@ -338,7 +338,7 @@ func queryImport(ctx context.Context, path string) (module.Version, error) {
canAdd := true
for _, bm := range buildList {
if bm.Path == cm.Path && semver.Compare(bm.Version, cm.Version) > 0 {
- // QueryPackage proposed that we add module cm to provide the package,
+ // QueryPattern proposed that we add module cm to provide the package,
// but we already depend on a newer version of that module (and we don't
// have the package).
//