Documentation
¶
Overview ¶
Package buildinfo provides functions for setting build information for CLIs and programs. Since CLIs and programs can be compiled, downloaded as a binary, or installed via `go install`, there's some nuanced logic in getting these values correct across all instances.
Consumers are encouraged to create an internal package in their module at "internal/version" with the following contents:
var ( Name = "my-program" Version = buildinfo.Version() Commit = buildinfo.Commit() OSArch = buildinfo.OSArch() HumanVersion = Name + " " + Version + " (" + Commit + ", " + OSArch + ")" )
These variables can then be referenced throughout the program. The values can still be overridden with LDFLAGS (which will take precedent over any values defined here).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Commit ¶
func Commit() string
Commit returns the VCS information, specifically the revision. Since most of our modules use Git, this is the Git SHA. If no SHA exists (e.g. outside of a repo), it returns "HEAD".
Types ¶
This section is empty.