Skip to content

Canonical version information injection target for Go's -ldflags

License

Notifications You must be signed in to change notification settings

digineo/goldflags

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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).

About

Canonical version information injection target for Go's -ldflags

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published