goldflags

package module
v0.0.0-...-f4bfb8d Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2019 License: AGPL-3.0 Imports: 9 Imported by: 7

README

goldflags

Canonical version information injection target for Go's -ldflags.

Use this snippet to inject Git-based version information into binaries:

COMMIT_ID   = $(shell git describe --tags --always --dirty=-dev)
COMMIT_UNIX = $(shell git show -s --format=%ct HEAD)
BUILD_COUNT = $(shell git rev-list --count HEAD)
BUILD_UNIX  = $(shell date +%s)

LDFLAGS = \
	-X 'github.com/digineo/goldflags.commitID=$(COMMIT_ID)' \
	-X 'github.com/digineo/goldflags.commitUnix=$(COMMIT_UNIX)' \
	-X 'github.com/digineo/goldflags.buildCount=$(BUILD_COUNT)' \
	-X 'github.com/digineo/goldflags.buildUnix=$(BUILD_UNIX)'

binary: main.go
	go build -ldflags "$(LDFLAGS)"

You can include the goldflags.mk to keep your Makefile tidy (cf. _examples/Makefile).

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Banner(appName string) string

Banner returns a pretty formatted version information banner

func BuildString

func BuildString() string

BuildString returns string containing build information (build date and number)

func ExpandPath

func ExpandPath(path string, base ...string) (result string, err error)

ExpandPath expands a path name. "~/" is expanded to the current user's home directory and "./" prepends the base path (defaults to ".", i.e. resulting in a no-op). After expansion, the result is cleaned (see filepath.Clean() for details).

func PathExist

func PathExist(path string) bool

PathExist checks whether a given path exists or not.

func ReadDir

func ReadDir(dir string) (names []string)

ReadDir returns a (non-recursive) list of file and directory names for the given directory path.

func VersionString

func VersionString() string

VersionString returns a combined version information string

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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