ldflags/README.md
fossabot 0d570a3cbd Add license scan report and status
Signed off by: fossabot <badges@fossa.com>
2020-10-08 12:02:15 -07:00

1.2 KiB

ldflags package

FOSSA Status

Package to store on-build extra information: version(tag), build hash, build time

Usage

Add this package as dependency to YOUR package:

go get github.com/version-go/ldflags 

Then on build of YOUR package just add extra:

go build -ldflags "-X 'github.com/version-go/ldflags.buildVersion=0.1.0' -X 'github.com/version-go/ldflags.buildHash=9e7637c' -X 'github.com/version-go/ldflags.buildTime=Sun Oct  4 20:57:29 CEST 2020'" .

Or do it automatically based on existing git/data:

go build -ldflags "-X 'github.com/version-go/ldflags.buildVersion=$(git describe --abbrev=0 --tags)' -X 'github.com/version-go/ldflags.buildHash=$(git rev-parse --short HEAD)' -X 'github.com/version-go/ldflags.buildTime=$(date)'" .

will store current latest tag, commit hash and build time.

License

FOSSA Status