]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go/internal/modload: ensure that modRoot and targetPrefix are initialized in...
authorBryan C. Mills <bcmills@google.com>
Thu, 29 Oct 2020 03:49:54 +0000 (23:49 -0400)
committerBryan C. Mills <bcmills@google.com>
Fri, 30 Oct 2020 18:05:53 +0000 (18:05 +0000)
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>

src/cmd/go/internal/modload/load.go

index f9c468c8b2c32e291d71eeadf4555d970abf2c55..0a84a1765a584ef51c62027b6eca9f2a869c1b7d 100644 (file)
@@ -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)