Skip to content

Commit

Permalink
cmd/go: properly call PackageModuleRoot to get modroot for index
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
matloob committed Jun 8, 2022
1 parent d651660 commit f862280
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/cmd/go/internal/load/pkg.go
Expand Up @@ -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
Expand Down

0 comments on commit f862280

Please sign in to comment.