From b6ac5354de85134b3994b3fbe2c0f33dd5845069 Mon Sep 17 00:00:00 2001 From: Metalblueberry Date: Tue, 8 Dec 2020 19:22:14 +0100 Subject: [PATCH] add build version --- cmd/chkb/build.sh | 3 +++ cmd/chkb/main.go | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100755 cmd/chkb/build.sh diff --git a/cmd/chkb/build.sh b/cmd/chkb/build.sh new file mode 100755 index 0000000..8ab5017 --- /dev/null +++ b/cmd/chkb/build.sh @@ -0,0 +1,3 @@ +#!/bin/bash +export VERSION=$(git describe --dirty) +go build -ldflags="-X 'main.Version=$VERSION'" \ No newline at end of file diff --git a/cmd/chkb/main.go b/cmd/chkb/main.go index 8ef7969..48f257b 100644 --- a/cmd/chkb/main.go +++ b/cmd/chkb/main.go @@ -19,6 +19,10 @@ import ( evdev "github.com/gvalkov/golang-evdev" ) +var ( + Version = "development" +) + func main() { var ( verbose bool @@ -27,7 +31,9 @@ func main() { flag.Parse() if verbose { log.SetLevel(log.DebugLevel) - log.Debug("Set debug level") + log. + WithField("Version", Version). + Debug("Set debug level") } dev, err := evdev.Open(flag.Arg(0))