aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/load/pkg.go
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2018-12-11 17:13:50 -0500
committerBryan C. Mills <bcmills@google.com>2019-07-18 19:06:47 +0000
commit4a2d3d06873559df2b6933f260dc8f75c54c9771 (patch)
tree4a323df3ac68b4ca07c654518c4a37adf3f2b4d1 /src/cmd/go/internal/load/pkg.go
parent5ba15db77f7ba92884b9a2fce21c9938c233967f (diff)
downloadgo-4a2d3d06873559df2b6933f260dc8f75c54c9771.tar.gz
go-4a2d3d06873559df2b6933f260dc8f75c54c9771.zip
cmd/go: in module mode, populate PackagePublic.Root with the module root
'go test' uses the Root field to determine the set of files that invalidate test results, and there is no other sensible meaning of “root” for code within a module. Fixes #29111 Change-Id: Icf1be90a26d22665613e42cb968087b63c36e74c Reviewed-on: https://go-review.googlesource.com/c/go/+/154100 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/load/pkg.go')
-rw-r--r--src/cmd/go/internal/load/pkg.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go
index 35b0790bc9..4eb4ba690f 100644
--- a/src/cmd/go/internal/load/pkg.go
+++ b/src/cmd/go/internal/load/pkg.go
@@ -64,7 +64,7 @@ type PackagePublic struct {
Doc string `json:",omitempty"` // package documentation string
Target string `json:",omitempty"` // installed target for this package (may be executable)
Shlib string `json:",omitempty"` // the shared library that contains this package (only set when -linkshared)
- Root string `json:",omitempty"` // Go root or Go path dir containing this package
+ Root string `json:",omitempty"` // Go root, Go path dir, or module root dir containing this package
ConflictDir string `json:",omitempty"` // Dir is hidden by this other directory
ForTest string `json:",omitempty"` // package is only for use in named test
Export string `json:",omitempty"` // file containing export data (set by go list -export)
@@ -647,6 +647,11 @@ func loadPackageData(path, parentPath, parentDir, parentRoot string, parentIsStd
buildMode = build.ImportComment
}
data.p, data.err = cfg.BuildContext.ImportDir(r.dir, buildMode)
+ if data.p.Root == "" && cfg.ModulesEnabled {
+ if info := ModPackageModuleInfo(path); info != nil {
+ data.p.Root = info.Dir
+ }
+ }
} else if r.err != nil {
data.p = new(build.Package)
data.err = fmt.Errorf("unknown import path %q: %v", r.path, r.err)