Skip to content

Commit

Permalink
Print version string with newline
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelmota committed Aug 6, 2020
1 parent 71d09da commit 0fed4d5
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions cointop/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ package cointop

import (
"fmt"
"os"
"runtime/debug"
)

// version is the cointop version which will be populated by ldflags
var version string = "(unknown)"
var version string

// Version returns the cointop version
func (ct *Cointop) Version() string {
Expand All @@ -16,18 +15,18 @@ func (ct *Cointop) Version() string {

// Version returns cointop version
func Version() string {
if version != "(unknown)" {
if version != "" {
return version
}

if buildInfo, ok := debug.ReadBuildInfo(); ok {
return buildInfo.Main.Version
}

return version
return "(devel)"
}

// PrintVersion prints the version
func PrintVersion() {
fmt.Fprint(os.Stdout, Version())
fmt.Println(Version())
}

0 comments on commit 0fed4d5

Please sign in to comment.