Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/digineo/goldflags
Canonical version information injection target for Go's -ldflags
https://github.com/digineo/goldflags
go ldflags
Last synced: 6 days ago
JSON representation
Canonical version information injection target for Go's -ldflags
- Host: GitHub
- URL: https://github.com/digineo/goldflags
- Owner: digineo
- License: agpl-3.0
- Created: 2017-06-09T08:47:44.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-11-22T00:22:36.000Z (almost 5 years ago)
- Last Synced: 2023-08-11T22:26:52.439Z (over 1 year ago)
- Topics: go, ldflags
- Language: Go
- Size: 15.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# goldflags
Canonical version information injection target for Go's -ldflags.
Use this snippet to inject Git-based version information into binaries:
```Makefile
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`).