1
0
mirror of https://github.com/golang/go synced 2024-11-23 00:30:07 -07:00

cmd/go: properly call PackageModuleRoot to get modroot for index

PackageModuleRoot needs to be called with the package's path, not
its directory on disk.

Change-Id: I080fe8ce2aeb72e1466624db81595a00915606bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/410820
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
This commit is contained in:
Michael Matloob 2022-06-07 13:54:53 -04:00
parent d65166024f
commit f862280e30

View File

@ -871,7 +871,7 @@ func loadPackageData(ctx context.Context, path, parentPath, parentDir, parentRoo
if !cfg.ModulesEnabled {
buildMode = build.ImportComment
}
if modroot := modload.PackageModRoot(ctx, r.dir); modroot != "" {
if modroot := modload.PackageModRoot(ctx, r.path); modroot != "" {
if mi, err := modindex.Get(modroot); err == nil {
data.p, data.err = mi.Import(cfg.BuildContext, mi.RelPath(r.dir), buildMode)
goto Happy