Enable setting rev via -ldflags

This commit is contained in:
Tim Van Baak 2025-05-02 15:00:19 -07:00
parent d80ac09122
commit cb6e3b72a8

View File

@ -2,8 +2,13 @@ package core
import "runtime/debug"
// Set via -ldflags "-X github.com/Jaculabilis/intake/core.Commit=..."
var Commit string = ""
func GetRevInfo() (rev string) {
rev = ""
rev = Commit
if rev == "" {
// No build data embedded, try from runtime/debug
if info, ok := debug.ReadBuildInfo(); ok {
for _, setting := range info.Settings {
if setting.Key == "vcs.revision" {
@ -14,5 +19,6 @@ func GetRevInfo() (rev string) {
}
}
}
}
return
}