From ab75014a1961e4e60f00a653e97e2383eff59d7b Mon Sep 17 00:00:00 2001 From: Balakrishnan Balasubramanian Date: Tue, 27 Dec 2022 22:24:27 -0500 Subject: [PATCH] Show git commit version on startup --- main.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index f9827e2..c96147c 100644 --- a/main.go +++ b/main.go @@ -10,6 +10,7 @@ import ( "net/http" "os" "path" + "runtime/debug" "strconv" "strings" "sync" @@ -51,7 +52,17 @@ func main() { glist.DataPath = dataPath - log.Printf("Grocery List bot starting with datapath:%s, port:%d\n", dataPath, port) + commit := "unknown" + + if bi, ok := debug.ReadBuildInfo(); ok { + for _, s := range bi.Settings { + if s.Key == "vcs.revision" { + commit = s.Value[:8] + } + } + } + + log.Printf("Grocery List bot (%s) starting with datapath:%s, port:%d\n", commit, dataPath, port) var chats sync.Map if err := loadData(dataPath, &chats); err != nil {