Commit 0eb38f2b authored by Manlio Perillo's avatar Manlio Perillo Committed by Bryan C. Mills
Browse files

cmd/go/internal/load: override Package.Root in module mode

The Context.ImportDir method in the go/build package sets Package.Root
to $GOPATH, if a package is inside a GOPATH workspace.  The
loadPackageData function keeps this value even when modules are enabled.

Override Package.Root when modules are enabled, instead of just set its
value when Context.ImportDir was unable to set it.

Add a regression test.

Fixes #46119

Change-Id: I900a33fe13a445cb771e2952d0d830f1b4a5921f
Reviewed-on: https://go-review.googlesource.com/c/go/+/319209


Reviewed-by: default avatarBryan C. Mills <bcmills@google.com>
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
parent a938e529
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment