aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/debug
diff options
context:
space:
mode:
authorAndrew Bonventre <andybons@google.com>2020-02-24 22:47:00 +0000
committerAndrew Bonventre <andybons@golang.org>2020-02-24 23:29:37 +0000
commit917c7a6fc9c6843e40da7f8e1a1fcf8605d1383e (patch)
tree0dbc8327321f94580f7e5ccc9c40c8a874caa9c6 /src/runtime/debug
parent2bfa8c37c3676d240ce947d58717fc8c0caa45f1 (diff)
downloadgo-917c7a6fc9c6843e40da7f8e1a1fcf8605d1383e.tar.xz
Revert "cmd/go/internal/modload: record the replacement for the module containing package main in BuildInfo"
This reverts CL 220645 (commit e092fc352ad393a4d2f1f7fa641df2d23572ccff). Reason for revert: Seems to have broken windows/amd64 longtest Change-Id: Iffa8c882524250e5845514bc827fcd8927645a44 Reviewed-on: https://go-review.googlesource.com/c/go/+/220722 Run-TryBot: Andrew Bonventre <andybons@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime/debug')
-rw-r--r--src/runtime/debug/mod.go51
1 files changed, 21 insertions, 30 deletions
diff --git a/src/runtime/debug/mod.go b/src/runtime/debug/mod.go
index 0381bdcc53..837cd689a0 100644
--- a/src/runtime/debug/mod.go
+++ b/src/runtime/debug/mod.go
@@ -47,27 +47,9 @@ func readBuildInfo(data string) (*BuildInfo, bool) {
repLine = "=>\t"
)
- readEntryFirstLine := func(elem []string) (Module, bool) {
- if len(elem) != 2 && len(elem) != 3 {
- return Module{}, false
- }
- sum := ""
- if len(elem) == 3 {
- sum = elem[2]
- }
- return Module{
- Path: elem[0],
- Version: elem[1],
- Sum: sum,
- }, true
- }
+ info := &BuildInfo{}
- var (
- info = &BuildInfo{}
- last *Module
- line string
- ok bool
- )
+ var line string
// Reverse of cmd/go/internal/modload.PackageBuildInfo
for len(data) > 0 {
i := strings.IndexByte(data, '\n')
@@ -81,33 +63,42 @@ func readBuildInfo(data string) (*BuildInfo, bool) {
info.Path = elem
case strings.HasPrefix(line, modLine):
elem := strings.Split(line[len(modLine):], "\t")
- last = &info.Main
- *last, ok = readEntryFirstLine(elem)
- if !ok {
+ if len(elem) != 3 {
return nil, false
}
+ info.Main = Module{
+ Path: elem[0],
+ Version: elem[1],
+ Sum: elem[2],
+ }
case strings.HasPrefix(line, depLine):
elem := strings.Split(line[len(depLine):], "\t")
- last = new(Module)
- info.Deps = append(info.Deps, last)
- *last, ok = readEntryFirstLine(elem)
- if !ok {
+ if len(elem) != 2 && len(elem) != 3 {
return nil, false
}
+ sum := ""
+ if len(elem) == 3 {
+ sum = elem[2]
+ }
+ info.Deps = append(info.Deps, &Module{
+ Path: elem[0],
+ Version: elem[1],
+ Sum: sum,
+ })
case strings.HasPrefix(line, repLine):
elem := strings.Split(line[len(repLine):], "\t")
if len(elem) != 3 {
return nil, false
}
- if last == nil {
+ last := len(info.Deps) - 1
+ if last < 0 {
return nil, false
}
- last.Replace = &Module{
+ info.Deps[last].Replace = &Module{
Path: elem[0],
Version: elem[1],
Sum: elem[2],
}
- last = nil
}
}
return info, true