aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/debug
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2024-10-22 17:21:33 -0700
committerGopher Robot <gobot@golang.org>2024-10-23 04:48:53 +0000
commit0c460ad0142b6ca1866272002f90fb8166ce4cc0 (patch)
treee31d18c957261fd5f89e6fa21da159293adf2140 /src/runtime/debug
parent7d9802ac5e8e16dddb7e4368172a1c1666fccb77 (diff)
downloadgo-0c460ad0142b6ca1866272002f90fb8166ce4cc0.tar.xz
runtime/debug: document ParseBuildInfo and (*BuildInfo).String
For #51026 Fixes #69971 Change-Id: I47f2938d20cbe9462bf738a506baedad4a7006c3 Reviewed-on: https://go-review.googlesource.com/c/go/+/621837 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/runtime/debug')
-rw-r--r--src/runtime/debug/mod.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/runtime/debug/mod.go b/src/runtime/debug/mod.go
index a4705605b8..8a1b1666bd 100644
--- a/src/runtime/debug/mod.go
+++ b/src/runtime/debug/mod.go
@@ -101,6 +101,7 @@ func quoteValue(value string) bool {
return strings.ContainsAny(value, " \t\r\n\"`")
}
+// String returns a string representation of a [BuildInfo].
func (bi *BuildInfo) String() string {
buf := new(strings.Builder)
if bi.GoVersion != "" {
@@ -146,6 +147,12 @@ func (bi *BuildInfo) String() string {
return buf.String()
}
+// ParseBuildInfo parses the string returned by [*BuildInfo.String],
+// restoring the original BuildInfo,
+// except that the GoVersion field is not set.
+// Programs should normally not call this function,
+// but instead call [ReadBuildInfo], [debug/buildinfo.ReadFile],
+// or [debug/buildinfo.Read].
func ParseBuildInfo(data string) (bi *BuildInfo, err error) {
lineNum := 1
defer func() {