From: Bryan C. Mills Date: Thu, 29 Oct 2020 03:49:54 +0000 (-0400) Subject: cmd/go/internal/modload: ensure that modRoot and targetPrefix are initialized in... X-Git-Tag: go1.16beta1~389 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=36d412f7548d90f4764c780a6f7d7da04bb90a9e;p=gostls13.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 Reviewed-by: Jay Conrod Reviewed-by: Michael Matloob TryBot-Result: Go Bot Trust: Bryan C. Mills --- diff --git a/src/cmd/go/internal/modload/load.go b/src/cmd/go/internal/modload/load.go index f9c468c8b2..0a84a1765a 100644 --- a/src/cmd/go/internal/modload/load.go +++ b/src/cmd/go/internal/modload/load.go @@ -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)