add git version at build time

This commit is contained in:
stryan 2021-03-02 14:37:31 -05:00
parent cf851b5021
commit a1c3b66705
2 changed files with 7 additions and 1 deletions

4
Makefile Normal file
View File

@ -0,0 +1,4 @@
GIT_COMMIT := $(shell git rev-list -1 HEAD)
all:
go build -ldflags "-X main.GitCommit=$(GIT_COMMIT)"

View File

@ -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 == "" {