Skip to content

Commit

Permalink
Read version from runtime build info if available
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelmota committed Aug 5, 2020
1 parent 1cd4c3c commit 523c430
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions cointop/version.go
Expand Up @@ -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
}

Expand Down

0 comments on commit 523c430

Please sign in to comment.