diff options
author | Michael Matloob <matloob@golang.org> | 2021-08-02 16:02:45 -0400 |
---|---|---|
committer | Michael Matloob <matloob@golang.org> | 2021-08-11 18:06:50 +0000 |
commit | aaf914d0e69198a96683c106abb5a931c4956f88 (patch) | |
tree | df56a6125db2ed28036813a0d179aae83d6cd89f /src/cmd/go/internal/modload/import.go | |
parent | 3025ce2fa83c86f3c802aab483535c39bad508ea (diff) | |
download | go-aaf914d0e69198a96683c106abb5a931c4956f88.tar.gz go-aaf914d0e69198a96683c106abb5a931c4956f88.zip |
[dev.cmdgo] cmd/go: remove modload.ModRoot function
In some cases, ModRoot was being called in a multi module context. In
those cases, pass in the correct main module. In other cases, a
mainModule variable was already available, so call MainModules.ModRoot
on that mainModule variable to make it more clear. In yet other cases
ModRoot is just needed to determine GoMod, so determine modroot from
the current directory in those cases.
For #45713
Change-Id: I8c8aa633cfae40d0c8740bdbf985f2b60c9daf2c
Reviewed-on: https://go-review.googlesource.com/c/go/+/339171
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Diffstat (limited to 'src/cmd/go/internal/modload/import.go')
-rw-r--r-- | src/cmd/go/internal/modload/import.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/cmd/go/internal/modload/import.go b/src/cmd/go/internal/modload/import.go index 5741299281..de47974b9b 100644 --- a/src/cmd/go/internal/modload/import.go +++ b/src/cmd/go/internal/modload/import.go @@ -294,7 +294,7 @@ func importFromModules(ctx context.Context, path string, rs *Requirements, mg *M if mainErr != nil { return module.Version{}, "", mainErr } - readVendorList() + readVendorList(mainModule) return vendorPkgModule[path], vendorDir, nil } @@ -653,11 +653,11 @@ func fetch(ctx context.Context, mod module.Version, needSum bool) (dir string, i if modRoot := MainModules.ModRoot(mod); modRoot != "" { return modRoot, true, nil } - if r, _ := Replacement(mod); r.Path != "" { + if r, replacedFrom := Replacement(mod); r.Path != "" { if r.Version == "" { dir = r.Path if !filepath.IsAbs(dir) { - dir = filepath.Join(ModRoot(), dir) + dir = filepath.Join(replacedFrom, dir) } // Ensure that the replacement directory actually exists: // dirInModule does not report errors for missing modules, |