Read version from runtime build info if available

pull/58/head v1.5.0
Miguel Mota 4 years ago
parent 1cd4c3c295
commit 523c43025a

@ -3,18 +3,27 @@ package cointop
import (
"fmt"
"os"
"runtime/debug"
)
// version is the cointop version which will be populated by ldflags
var version = "dev"
var version string = "(unknown)"
// Version returns the cointop version
func (ct *Cointop) Version() string {
return version
return Version()
}
// Version returns cointop version
func Version() string {
if version != "(unknown)" {
return version
}
if buildInfo, ok := debug.ReadBuildInfo(); ok {
return buildInfo.Main.Version
}
return version
}

Loading…
Cancel
Save