Enable setting rev via -ldflags
This commit is contained in:
parent
d80ac09122
commit
cb6e3b72a8
22
core/info.go
22
core/info.go
@ -2,15 +2,21 @@ package core
|
|||||||
|
|
||||||
import "runtime/debug"
|
import "runtime/debug"
|
||||||
|
|
||||||
|
// Set via -ldflags "-X github.com/Jaculabilis/intake/core.Commit=..."
|
||||||
|
var Commit string = ""
|
||||||
|
|
||||||
func GetRevInfo() (rev string) {
|
func GetRevInfo() (rev string) {
|
||||||
rev = ""
|
rev = Commit
|
||||||
if info, ok := debug.ReadBuildInfo(); ok {
|
if rev == "" {
|
||||||
for _, setting := range info.Settings {
|
// No build data embedded, try from runtime/debug
|
||||||
if setting.Key == "vcs.revision" {
|
if info, ok := debug.ReadBuildInfo(); ok {
|
||||||
rev = setting.Value + rev
|
for _, setting := range info.Settings {
|
||||||
}
|
if setting.Key == "vcs.revision" {
|
||||||
if setting.Key == "vcs.modified" && setting.Value == "true" {
|
rev = setting.Value + rev
|
||||||
rev = rev + "-dirty"
|
}
|
||||||
|
if setting.Key == "vcs.modified" && setting.Value == "true" {
|
||||||
|
rev = rev + "-dirty"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user