Documentation
¶
Overview ¶
Package buildinfo provides a collection of helpers to make introspecting a build as a human or a machine easier.
To use this library, you'll need to update your CI builds to include the relevant information. For example, if you have a shell script building your project, it could be updated like such:
BUILD_TIME=$(date +%s)
BUILD_HASH=$(git rev-parse --short HEAD)
RELEASE_VERSION=${RELEASE_VERSION:-dev}
BUILD_URL=${BUILD_URL:-}
LDFLAGS=""
LDFLAGS="$LDFLAGS -X github.com/daaku/buildinfo.buildTimeUnix=$BUILD_TIME"
LDFLAGS="$LDFLAGS -X github.com/daaku/buildinfo.buildHash=$BUILD_HASH"
LDFLAGS="$LDFLAGS -X github.com/daaku/buildinfo.releaseVersion=$RELEASE_VERSION"
LDFLAGS="$LDFLAGS -X github.com/daaku/buildinfo.buildURL=$BUILD_URL"
go build \
-trimpath \
-ldflags "$LDFLAGS" \
-o myapp \
github.com/me/myapp
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BasicInfo ¶
func BasicInfo() []byte
BasicInfo returns a pretty-print version of various useful pieces of build information.
func BuildHash ¶
func BuildHash() string
BuildHash returns the release hash of this built binary. It may return "dev" if a build hash isn't avaiable.
func FullInfo ¶
func FullInfo() []byte
FullInfo provide a combined pretty printed information containing build info as well as module info.
func ModuleInfo ¶
func ModuleInfo() string
ModuleInfo provides a pretty table with the modules and corresponding versions.
func ReleaseVersion ¶
func ReleaseVersion() string
ReleaseVersion returns the release version of this built binary. It may return "dev" if a build version isn't avaiable.
func StartupTime ¶
StartupTime returns the time at which this binary was executed.
Types ¶
This section is empty.