diff options
author | Bryan C. Mills <bcmills@google.com> | 2020-02-27 15:52:32 -0500 |
---|---|---|
committer | Bryan C. Mills <bcmills@google.com> | 2020-02-28 19:05:54 +0000 |
commit | d11e1f92fc578c5d2e604acfe9ea60d7afb84a0c (patch) | |
tree | 7903355bf2672af603635dd928b8d1aad8967d22 /src/cmd/go/internal/modload/query.go | |
parent | 156c60709e7775a6f1baa9685155b5974fefdea9 (diff) | |
download | go-d11e1f92fc578c5d2e604acfe9ea60d7afb84a0c.tar.gz go-d11e1f92fc578c5d2e604acfe9ea60d7afb84a0c.zip |
cmd/go/internal/search: consolidate package-pattern predicates into Match methods
This change consolidates predicates currently scattered throughout
various parts of the package and module loader into methods on the
search.Match type.
That not only makes them more concise, but also encourages
consistency, both in the code and in reasoning about the kinds of
patterns that need to be handled. (For example, the IsLocal predicate
was previously two different calls, either of which could be easily
forgotten at a given call site.)
Factored out from CL 185344 and CL 185345.
Updates #32917
Change-Id: Ifa450ffaf6101f673e0ed69ced001a487d6f9335
Reviewed-on: https://go-review.googlesource.com/c/go/+/221458
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <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/query.go')
-rw-r--r-- | src/cmd/go/internal/modload/query.go | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/cmd/go/internal/modload/query.go b/src/cmd/go/internal/modload/query.go index cf0dd3ff6e..b490220b24 100644 --- a/src/cmd/go/internal/modload/query.go +++ b/src/cmd/go/internal/modload/query.go @@ -381,7 +381,8 @@ type QueryResult struct { // module and only the version "latest", without checking for other possible // modules. func QueryPackage(path, query string, allowed func(module.Version) bool) ([]QueryResult, error) { - if search.IsMetaPackage(path) || strings.Contains(path, "...") { + m := search.NewMatch(path) + if m.IsLocal() || !m.IsLiteral() { return nil, fmt.Errorf("pattern %s is not an importable package", path) } return QueryPattern(path, query, allowed) |