Standard library / runtime/debug

debug.ReadBuildInfo()

Reads embedded build metadata from the running executable; check the boolean result. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func ReadBuildInfo() (info *BuildInfo, ok bool)

Return Value

(info *BuildInfo, ok bool)

Build metadata and whether it is available.

Working Example

Example Snippetgo
package main
import (  "fmt"  "runtime/debug")
func main() { info, ok := debug.ReadBuildInfo(); fmt.Println(ok && info.GoVersion != "") }
Go Reference