mirror of https://github.com/golang/go.git
cmd/go/internal/modload: ensure that modRoot and targetPrefix are initialized in DirImportPath
For #37438 Change-Id: I2e1f47d567842ac5504b7b8ed0b3fba6f92d778b Reviewed-on: https://go-review.googlesource.com/c/go/+/266340 Run-TryBot: Bryan C. Mills <bcmills@google.com> Reviewed-by: Jay Conrod <jayconrod@google.com> Reviewed-by: Michael Matloob <matloob@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Trust: Bryan C. Mills <bcmills@google.com>
This commit is contained in:
parent
34665c63ff
commit
36d412f754
|
|
@ -520,9 +520,10 @@ func ImportFromFiles(ctx context.Context, gofiles []string) {
|
|||
// DirImportPath returns the effective import path for dir,
|
||||
// provided it is within the main module, or else returns ".".
|
||||
func DirImportPath(dir string) string {
|
||||
if modRoot == "" {
|
||||
if !HasModRoot() {
|
||||
return "."
|
||||
}
|
||||
LoadModFile(context.TODO())
|
||||
|
||||
if !filepath.IsAbs(dir) {
|
||||
dir = filepath.Join(base.Cwd, dir)
|
||||
|
|
|
|||
Loading…
Reference in New Issue