From a1c3b66705588eb50370d1cf270a002929e50236 Mon Sep 17 00:00:00 2001 From: Steve Date: Tue, 2 Mar 2021 14:37:31 -0500 Subject: [PATCH] add git version at build time --- Makefile | 4 ++++ main.go | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f2e404d --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +GIT_COMMIT := $(shell git rev-list -1 HEAD) + +all: + go build -ldflags "-X main.GitCommit=$(GIT_COMMIT)" diff --git a/main.go b/main.go index c7b8eae..0cf0f1f 100644 --- a/main.go +++ b/main.go @@ -15,9 +15,11 @@ var cookieHandler = securecookie.New( securecookie.GenerateRandomKey(64), securecookie.GenerateRandomKey(32)) var passwordTokenSet map[string]bool +var GitCommit string func main() { Conf, _ = LoadConfig() + version := GitCommit log.Println("Loaded config") router := mux.NewRouter().StrictSlash(true) router.HandleFunc("/", homePage).Methods("GET") @@ -56,7 +58,7 @@ func main() { log.Printf("Max employeeNumber set to %v\n", Conf.MaxID) } passwordTokenSet = make(map[string]bool) - log.Printf("Guildgate starting on %v\n", Conf.Port) + log.Printf("Guildgate v%v starting on %v\n", version, Conf.Port) if Conf.Tls { log.Printf("Starting TLS\n") if Conf.Cert == "" {