aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/modload/load.go
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2020-05-06 16:22:15 -0400
committerBryan C. Mills <bcmills@google.com>2020-05-13 18:51:10 +0000
commit14bec27743365511495eadb2accf76efaccbc525 (patch)
tree5af6e61b7e5e5633750688e6869b16aeff19ff1f /src/cmd/go/internal/modload/load.go
parentb819adfe6d3bb53b1c863d5c5a8b64b89698d9f7 (diff)
downloadgo-14bec27743365511495eadb2accf76efaccbc525.tar.gz
go-14bec27743365511495eadb2accf76efaccbc525.zip
cmd/go: do not ignore permission errors when matching patterns
While reviewing CL 228784, I noticed that various filepath.WalkFunc implementations within cmd/go were dropping non-nil errors. Those errors turn out to be significant, at least in some cases: for example, they can cause packages to appear to be missing when any parent of the directory had the wrong permissions set. (This also turned up a bug in the existing list_dedup_packages test, which was accidentally passing a nonexistent directory instead of the intended duplicate path.) Change-Id: Ia09a0a33aa7a966d9f132d3747d6c674a5370b2d Reviewed-on: https://go-review.googlesource.com/c/go/+/232579 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
Diffstat (limited to 'src/cmd/go/internal/modload/load.go')
-rw-r--r--src/cmd/go/internal/modload/load.go21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/cmd/go/internal/modload/load.go b/src/cmd/go/internal/modload/load.go
index 8a02c750e1..30992e0cc2 100644
--- a/src/cmd/go/internal/modload/load.go
+++ b/src/cmd/go/internal/modload/load.go
@@ -99,14 +99,16 @@ func ImportPathsQuiet(patterns []string, tags map[string]bool) []*search.Match {
m.Pkgs = []string{m.Pattern()}
case strings.Contains(m.Pattern(), "..."):
- m.Pkgs = matchPackages(m.Pattern(), loaded.tags, true, buildList)
+ m.Errs = m.Errs[:0]
+ matchPackages(m, loaded.tags, includeStd, buildList)
case m.Pattern() == "all":
loaded.testAll = true
if iterating {
// Enumerate the packages in the main module.
// We'll load the dependencies as we find them.
- m.Pkgs = matchPackages("...", loaded.tags, false, []module.Version{Target})
+ m.Errs = m.Errs[:0]
+ matchPackages(m, loaded.tags, omitStd, []module.Version{Target})
} else {
// Starting with the packages in the main module,
// enumerate the full list of "all".
@@ -273,7 +275,9 @@ func resolveLocalPackage(dir string) (string, error) {
}
pkg := targetPrefix + suffix
- if _, ok := dirInModule(pkg, targetPrefix, modRoot, true); !ok {
+ if _, ok, err := dirInModule(pkg, targetPrefix, modRoot, true); err != nil {
+ return "", err
+ } else if !ok {
return "", &PackageNotInModuleError{Mod: Target, Pattern: pkg}
}
return pkg, nil
@@ -422,7 +426,7 @@ func loadAll(testAll bool) []string {
loaded.testRoots = true
}
all := TargetPackages("...")
- loaded.load(func() []string { return all })
+ loaded.load(func() []string { return all.Pkgs })
checkMultiplePaths()
WriteGoMod()
@@ -434,6 +438,9 @@ func loadAll(testAll bool) []string {
}
paths = append(paths, pkg.path)
}
+ for _, err := range all.Errs {
+ base.Errorf("%v", err)
+ }
base.ExitIfErrors()
return paths
}
@@ -441,12 +448,14 @@ func loadAll(testAll bool) []string {
// TargetPackages returns the list of packages in the target (top-level) module
// matching pattern, which may be relative to the working directory, under all
// build tag settings.
-func TargetPackages(pattern string) []string {
+func TargetPackages(pattern string) *search.Match {
// TargetPackages is relative to the main module, so ensure that the main
// module is a thing that can contain packages.
ModRoot()
- return matchPackages(pattern, imports.AnyTags(), false, []module.Version{Target})
+ m := search.NewMatch(pattern)
+ matchPackages(m, imports.AnyTags(), omitStd, []module.Version{Target})
+ return m
}
// BuildList returns the module build list,