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/load/pkg.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/load/pkg.go')
-rw-r--r-- | src/cmd/go/internal/load/pkg.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go index 723985f1f8..9bf7c228b7 100644 --- a/src/cmd/go/internal/load/pkg.go +++ b/src/cmd/go/internal/load/pkg.go @@ -2074,13 +2074,13 @@ func PackagesAndErrors(patterns []string) []*Package { for _, m := range matches { for _, pkg := range m.Pkgs { if pkg == "" { - panic(fmt.Sprintf("ImportPaths returned empty package for pattern %s", m.Pattern)) + panic(fmt.Sprintf("ImportPaths returned empty package for pattern %s", m.Pattern())) } p := loadImport(pre, pkg, base.Cwd, nil, &stk, nil, 0) - p.Match = append(p.Match, m.Pattern) + p.Match = append(p.Match, m.Pattern()) p.Internal.CmdlinePkg = true - if m.Literal { - // Note: do not set = m.Literal unconditionally + if m.IsLiteral() { + // Note: do not set = m.IsLiteral unconditionally // because maybe we'll see p matching both // a literal and also a non-literal pattern. p.Internal.CmdlinePkgLiteral = true |