From 12990ad2e2f1efa353ab6da3d1a2d5620ff72c37 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 4 Oct 2020 21:04:31 +0200 Subject: [PATCH] Proper readme info. --- README.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 162905b..5160d9a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,20 @@ -# ldflags +# ldflags package Package to store on-build extra information: version(tag), build hash, build time + + +## Usage +Add this package as dependency to YOUR package: +```bash +go get github.com/version-go/ldflags +``` + +Then on build of YOUR package just add extra: +```bash +go build -ldflags "-X 'github.com/version-go/ldflags.version=0.1.0' -X 'github.com/version-go/ldflags.hash=9e7637c' -X 'github.com/version-go/ldflags.time=Sun Oct 4 20:57:29 CEST 2020'" . +``` + +Or do it automatically based on existing git/data: +```bash +go build -ldflags "-X 'github.com/version-go/ldflags.version=$(git describe --abbrev=0 --tags)' -X 'github.com/version-go/ldflags.hash=$(git rev-parse --short HEAD)' -X 'github.com/version-go/ldflags.time=$(date)'" . +``` +will store current latest tag, commit hash and build time.