aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/modload/build.go
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2020-02-25 14:58:30 +0000
committerBryan C. Mills <bcmills@google.com>2020-02-25 15:43:19 +0000
commit987e4e892325ea91a15a34f7a858ab007fea39c4 (patch)
treeb5b607d959ac8745d18b5a02ec76b2e58e6a7e90 /src/cmd/go/internal/modload/build.go
parentb2696fde403a5b059936ac6dd22b6ec9a899e084 (diff)
downloadgo-987e4e892325ea91a15a34f7a858ab007fea39c4.tar.gz
go-987e4e892325ea91a15a34f7a858ab007fea39c4.zip
Revert "Revert "cmd/go/internal/modload: record the replacement for the module containing package main in BuildInfo""
This reverts CL 220722. Reason for revert: rolling forward with fix. Fixes #37392 Change-Id: Iba8b0c645267777fbb7019976292d691a10b906a Reviewed-on: https://go-review.googlesource.com/c/go/+/220898 Run-TryBot: Bryan C. Mills <bcmills@google.com> Reviewed-by: Jay Conrod <jayconrod@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/cmd/go/internal/modload/build.go')
-rw-r--r--src/cmd/go/internal/modload/build.go30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/cmd/go/internal/modload/build.go b/src/cmd/go/internal/modload/build.go
index 6fa47d7400..454dbf28cf 100644
--- a/src/cmd/go/internal/modload/build.go
+++ b/src/cmd/go/internal/modload/build.go
@@ -207,6 +207,7 @@ func PackageBuildInfo(path string, deps []string) string {
if isStandardImportPath(path) || !Enabled() {
return ""
}
+
target := mustFindModule(path, path)
mdeps := make(map[module.Version]bool)
for _, dep := range deps {
@@ -223,26 +224,25 @@ func PackageBuildInfo(path string, deps []string) string {
var buf bytes.Buffer
fmt.Fprintf(&buf, "path\t%s\n", path)
- tv := target.Version
- if tv == "" {
- tv = "(devel)"
- }
- fmt.Fprintf(&buf, "mod\t%s\t%s\t%s\n", target.Path, tv, modfetch.Sum(target))
- for _, mod := range mods {
- mv := mod.Version
+
+ writeEntry := func(token string, m module.Version) {
+ mv := m.Version
if mv == "" {
mv = "(devel)"
}
- r := Replacement(mod)
- h := ""
- if r.Path == "" {
- h = "\t" + modfetch.Sum(mod)
- }
- fmt.Fprintf(&buf, "dep\t%s\t%s%s\n", mod.Path, mv, h)
- if r.Path != "" {
- fmt.Fprintf(&buf, "=>\t%s\t%s\t%s\n", r.Path, r.Version, modfetch.Sum(r))
+ fmt.Fprintf(&buf, "%s\t%s\t%s", token, m.Path, mv)
+ if r := Replacement(m); r.Path == "" {
+ fmt.Fprintf(&buf, "\t%s\n", modfetch.Sum(m))
+ } else {
+ fmt.Fprintf(&buf, "\n=>\t%s\t%s\t%s\n", r.Path, r.Version, modfetch.Sum(r))
}
}
+
+ writeEntry("mod", target)
+ for _, mod := range mods {
+ writeEntry("dep", mod)
+ }
+
return buf.String()
}