diff options
author | Michael Matloob <matloob@golang.org> | 2021-07-04 13:27:18 -0400 |
---|---|---|
committer | Michael Matloob <matloob@golang.org> | 2021-07-30 23:47:39 +0000 |
commit | b3b53e1dad8681e3c21522513e4539813a5a3de7 (patch) | |
tree | afc615fe1c7a6e33c361e0c96a28c9685578e2ce /src/cmd/go/internal/modload/import.go | |
parent | 47694b59eb30bfe6a1c12a2eaaf631a4e956b9c7 (diff) | |
download | go-b3b53e1dad8681e3c21522513e4539813a5a3de7.tar.gz go-b3b53e1dad8681e3c21522513e4539813a5a3de7.zip |
[dev.cmdgo] cmd/go: thread through modroots providing replacements
modload.Replacement and modload.resolveReplacement now also return
the modroot of the module providing a replacement so that we can
correctly construct the path of a replaced module (because the
path in the module.Version is relative to the modroot).
For #45713
Change-Id: I8c69ccbcc1f40201071e35fcf93d6b5d0ed4cdf7
Reviewed-on: https://go-review.googlesource.com/c/go/+/334941
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 | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/cmd/go/internal/modload/import.go b/src/cmd/go/internal/modload/import.go index 088d0c14ec..5741299281 100644 --- a/src/cmd/go/internal/modload/import.go +++ b/src/cmd/go/internal/modload/import.go @@ -479,11 +479,12 @@ func queryImport(ctx context.Context, path string, rs *Requirements) (module.Ver // The package path is not valid to fetch remotely, // so it can only exist in a replaced module, // and we know from the above loop that it is not. + replacement, _ := Replacement(mods[0]) return module.Version{}, &PackageNotInModuleError{ Mod: mods[0], Query: "latest", Pattern: path, - Replacement: Replacement(mods[0]), + Replacement: replacement, } } @@ -652,7 +653,7 @@ 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, _ := Replacement(mod); r.Path != "" { if r.Version == "" { dir = r.Path if !filepath.IsAbs(dir) { |