Show git commit version on startup

This commit is contained in:
Balakrishnan Balasubramanian 2022-12-27 22:24:27 -05:00
parent 0354436ab6
commit ab75014a19

13
main.go
View File

@ -10,6 +10,7 @@ import (
"net/http" "net/http"
"os" "os"
"path" "path"
"runtime/debug"
"strconv" "strconv"
"strings" "strings"
"sync" "sync"
@ -51,7 +52,17 @@ func main() {
glist.DataPath = dataPath 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 var chats sync.Map
if err := loadData(dataPath, &chats); err != nil { if err := loadData(dataPath, &chats); err != nil {