Help us shape the future of Go! Take the 2026 Go Developer Survey

buildinfo

package
v1.3.102 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package buildinfo pkg/buildinfo/buildinfo.go c0-com-util

The encoding/json-using init() that parses ldflags-injected `go list -m -json` output lives in buildinfo_native.go (!js). Under js/wasm, ldflags injection is not the typical path — the install-page WASM is rebuilt against the latest skywire dependency, not with custom -X overrides — so the json parse is effectively dead code there. Build-tag-gating it lets TinyGo strip encoding/json's reflect runtime helpers from the WASM bundle.

Package buildinfo pkg/buildinfo/buildinfo_native.go c0-com-util

Native init() that parses the ldflags-injected `go list -m -json` output via encoding/json. Build-tag-gated off the WASM path — see buildinfo.go's package doc for the rationale.

Index

Constants

View Source
const VersionHeader = "SW-Version"

VersionHeader carries a visor's version on its requests to deployment services, which count requests by it.

Variables

This section is empty.

Functions

func BuildTags

func BuildTags() string

BuildTags returns the build tags recorded by the Go toolchain (the "-tags" build setting), or "" if none / unavailable.

func Commit

func Commit() string

Commit returns the extracted commit hash.

func DBIVersion

func DBIVersion() string

DBIVersion returns bi.Main.Version.

func Date

func Date() string

Date returns the extracted build date in RFC3339 format.

func DebugBuildInfo

func DebugBuildInfo() *debug.BuildInfo

DebugBuildInfo returns the raw debug.BuildInfo struct.

func DepVersion

func DepVersion(modulePath string) string

DepVersion returns the version of a specific dependency module. modulePath should be something like "github.com/skycoin/skycoin"

func Go

func Go() string

Go returns the Go compiler version used for the build.

func Version

func Version() string

Version returns the extracted version string.

func VersionOrCommit

func VersionOrCommit() string

VersionOrCommit returns Version() when a real (non-devel) version is known, otherwise a "dev-<short-commit>[-dirty]" string derived from the VCS info the Go/TinyGo toolchain records automatically (vcs.revision / vcs.modified). It lets a build that injects no version via ldflags — the wasm-visor, whose blob is compiled at an earlier commit than the binary that embeds it and so cannot borrow the host's version — still self-describe the commit it was built from instead of reporting "unknown". Returns unknown only when neither a version nor a commit is recorded.

Types

type Info

type Info struct {
	Go        string `json:"go,omitempty"`
	Version   string `json:"version"`
	Commit    string `json:"commit"`
	Date      string `json:"date"`
	OS        string `json:"os"`
	Arch      string `json:"arch"`
	BuildTags string `json:"build_tags,omitempty"`
}

Info represents build metadata.

func Get

func Get() *Info

Get returns a summary of build information.

func (*Info) WriteTo

func (info *Info) WriteTo(w io.Writer) (int64, error)

WriteTo writes build info summary to an io.Writer.

type ModuleInfo

type ModuleInfo struct {
	Version string `json:"Version"`
	Origin  struct {
		Hash string `json:"Hash"`
	} `json:"Origin"`
}

ModuleInfo represents the JSON structure returned by `go list -m -json`.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL