Standard library / runtime/debug

debug.BuildInfo

Describes the Go version, main module, dependencies and build settings when available. Not all binaries contain all fields. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
type BuildInfo struct {  GoVersion string
  Path string
  Main Module
  Deps []*Module
  Settings []BuildSetting}

Working Example

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