gitlin/utils/version.go
Odyssey a4a4e15673 Make version a utility function
Signed-off-by: Odyssey <odyssey346@disroot.org>
2023-01-05 20:46:49 +01:00

18 行
401 B
Go

package utils
import (
"runtime/debug"
)
// Version returns the git commit hash of the current build. Taken from https://git.vern.cc/pjals/bestofbot.
func Version() string {
if info, ok := debug.ReadBuildInfo(); ok {
for _, setting := range info.Settings {
if setting.Key == "vcs.revision" {
return setting.Value[:8]
}
}
}
return "unknown, please build with Go 1.13+ or use Git"
}