From b67b5d6b7edfee072010153c36930d1d5b4d7005 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Sun, 21 Aug 2022 20:46:40 +0200 Subject: [PATCH] src/main.go: use a global variable to display version number, this should be set by the linker during build. --- src/main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main.go b/src/main.go index 6177396..319c92b 100644 --- a/src/main.go +++ b/src/main.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "os" "os/signal" "syscall" @@ -18,6 +19,10 @@ var pidFile string // Global variables // --------------------------------------------------------- +// Version string, should be updated by the go linker (by passing "-X main.VersionString=value" to the linker) +// see: https://pkg.go.dev/cmd/link and +var VersionString string = "-" + // File descriptor to the current log file. var logfd *os.File @@ -135,7 +140,7 @@ func main() { } if version { - print("Version: v1.2.2\n") + fmt.Printf("Version: %s\n", VersionString) return; }