From 6f286490beb89ab332d02f7ab1658782066ef38b Mon Sep 17 00:00:00 2001 From: Miguel Mota Date: Sun, 17 Nov 2019 23:09:08 -0800 Subject: [PATCH] Fix ldflags version --- .goreleaser.yml | 2 +- cointop/statusbar.go | 7 ++++++- cointop/version.go | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index e6aed34..e8f3563 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -7,4 +7,4 @@ builds: goarch: - amd64 ldflags: - - -X main.version={{.Env.VERSION}} + - -X github.com/miguelmota/cointop/cointop.version={{.Env.VERSION}} diff --git a/cointop/statusbar.go b/cointop/statusbar.go index 65f917c..87e830f 100644 --- a/cointop/statusbar.go +++ b/cointop/statusbar.go @@ -56,7 +56,12 @@ func (ct *Cointop) updateStatusbar(s string) error { base := fmt.Sprintf("%s%s %sHelp %sChart %sRange %sSearch %sConvert %s %s %sSave", "[Q]", quitText, "[?]", "[Enter]", "[[ ]]", "[/]", "[C]", favoritesText, portfolioText, "[CTRL-S]") str := pad.Right(fmt.Sprintf("%v %sPage %v/%v %s", base, "[← →]", currpage, totalpages, s), ct.maxTableWidth, " ") v := fmt.Sprintf("v%s", ct.Version()) - str = str[:len(str)-len(v)+2] + v + end := len(str) - len(v) + 2 + if end > len(str) { + end = len(str) + } + + str = str[:end] + v ct.update(func() { ct.Views.Statusbar.Update(str) diff --git a/cointop/version.go b/cointop/version.go index a62d6c3..e9cad6a 100644 --- a/cointop/version.go +++ b/cointop/version.go @@ -6,7 +6,7 @@ import ( ) // version is the cointop version which will be populated by ldflags -var version string +var version = "dev" // Version returns the cointop version func (ct *Cointop) Version() string {