buildinfo

package module
v1.0.2-0...-ae269e1 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2020 License: MIT Imports: 7 Imported by: 1

README

buildinfo

Package buildinfo provides a collection of helpers to make introspecting a build as a human or a machine easier.

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 BuildTime

func BuildTime() time.Time

BuildTime returns the time at which this binary was built.

func BuildURL

func BuildURL() string

BuildURL returns the URL for the CI build. It may be blank.

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

func StartupTime() time.Time

StartupTime returns the time at which this binary was executed.

Types

This section is empty.

Jump to

Keyboard shortcuts

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