mirror of
https://github.com/ncarlier/webhookd.git
synced 2024-09-20 00:45:29 +00:00
parent
361770b898
commit
0c41f76f53
|
@ -3,6 +3,8 @@ package version
|
|||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"runtime/debug"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Version of the app
|
||||
|
@ -28,3 +30,26 @@ This is free software: you are free to change and redistribute it.
|
|||
There is NO WARRANTY, to the extent permitted by law.
|
||||
`, Version, GitCommit, Built)
|
||||
}
|
||||
|
||||
func init() {
|
||||
if GitCommit != "snapshot" {
|
||||
return
|
||||
}
|
||||
info, ok := debug.ReadBuildInfo()
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
Version = info.Main.Version
|
||||
for _, kv := range info.Settings {
|
||||
if kv.Value == "" {
|
||||
continue
|
||||
}
|
||||
switch kv.Key {
|
||||
case "vcs.revision":
|
||||
GitCommit = kv.Value[:7]
|
||||
case "vcs.time":
|
||||
lastCommit, _ := time.Parse(time.RFC3339, kv.Value)
|
||||
Built = lastCommit.Format(time.RFC1123)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user