aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/modload/build.go
diff options
context:
space:
mode:
authorMichael Matloob <matloob@golang.org>2021-08-02 16:02:45 -0400
committerMichael Matloob <matloob@golang.org>2021-08-11 18:06:50 +0000
commitaaf914d0e69198a96683c106abb5a931c4956f88 (patch)
treedf56a6125db2ed28036813a0d179aae83d6cd89f /src/cmd/go/internal/modload/build.go
parent3025ce2fa83c86f3c802aab483535c39bad508ea (diff)
downloadgo-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/build.go')
-rw-r--r--src/cmd/go/internal/modload/build.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/cmd/go/internal/modload/build.go b/src/cmd/go/internal/modload/build.go
index 2973586479..3f2160d52d 100644
--- a/src/cmd/go/internal/modload/build.go
+++ b/src/cmd/go/internal/modload/build.go
@@ -323,7 +323,7 @@ func moduleInfo(ctx context.Context, rs *Requirements, m module.Version, mode Li
if filepath.IsAbs(r.Path) {
info.Replace.Dir = r.Path
} else {
- info.Replace.Dir = filepath.Join(ModRoot(), r.Path)
+ info.Replace.Dir = filepath.Join(replacedFrom, r.Path)
}
info.Replace.GoMod = filepath.Join(info.Replace.Dir, "go.mod")
}