Documentation
¶
Overview ¶
Package buildinfo carries the values stamped into the binary at link time (§16.4) and degrades gracefully when they are absent.
cmd/pay/main.go declares the -X targets (main.version / main.commit / main.date) and hands them to Set before anything else runs. When the binary was produced by "go install .../cmd/pay@latest" instead of goreleaser, the ldflags are empty and the module version plus VCS stamps recorded by the Go toolchain in debug.ReadBuildInfo are used instead, so `pay version` reports something more useful than "dev".
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Commit ¶
func Commit() string
Commit is the VCS revision the binary was built from, or "" when unknown.
func Set ¶
func Set(version, commit, date string)
Set records the link-time values. It is called exactly once, from cmd/pay/main.go, before any other package runs.
Types ¶
type Info ¶
type Info struct {
Version string `json:"version"`
Commit string `json:"commit"`
Date string `json:"date"`
Go string `json:"go"`
OS string `json:"os"`
Arch string `json:"arch"`
InstallPath string `json:"install_path"`
Managed bool `json:"managed"`
}
Info is the payload of `pay version --output json` (§16.4). InstallPath and Managed are filled in by the caller (internal/update knows whether the binary sits in a package-manager-owned location); every other field is resolved here.