Standard library / runtime/debug

debug.BuildInfo.String()

Formats build metadata into the textual representation accepted by ParseBuildInfo. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func (bi *BuildInfo) String() string

Return Value

string

Text representation of the build metadata.

Working Example

Example Snippetgo
package main
import (  "fmt"  "runtime/debug")
func main() {  info := &debug.BuildInfo{GoVersion: "go1.23.2", Path: "example.invalid/demo"}  parsed, err := debug.ParseBuildInfo(info.String())  fmt.Println(err == nil && parsed.Path == info.Path)}
Go Reference