From 68ff8ecfb72eb0f99af3d612ca952b1e02784d30 Mon Sep 17 00:00:00 2001 From: Miguel Mota Date: Sun, 31 Jan 2021 22:42:53 -0800 Subject: [PATCH] Format fixes --- cointop/cointop.go | 4 ++-- cointop/size.go | 4 ++-- cointop/sort.go | 6 ++---- cointop/statusbar.go | 2 +- cointop/table.go | 3 +-- cointop/update.go | 4 +--- pkg/api/impl/coingecko/coingecko.go | 4 ++-- pkg/api/impl/coinmarketcap/coinmarketcap.go | 4 ++-- 8 files changed, 13 insertions(+), 18 deletions(-) diff --git a/cointop/cointop.go b/cointop/cointop.go index 022350a..f7b7102 100644 --- a/cointop/cointop.go +++ b/cointop/cointop.go @@ -22,7 +22,7 @@ import ( // TODO: clean up and optimize codebase // ErrInvalidAPIChoice is error for invalid API choice -var ErrInvalidAPIChoice = errors.New("Invalid API choice") +var ErrInvalidAPIChoice = errors.New("invalid API choice") // Views are all views in cointop type Views struct { @@ -229,7 +229,7 @@ func NewCointop(config *Config) (*Cointop, error) { page: 0, perPage: int(perPage), portfolio: &Portfolio{ - Entries: make(map[string]*PortfolioEntry, 0), + Entries: make(map[string]*PortfolioEntry), }, portfolioTableColumns: DefaultPortfolioTableHeaders, chartHeight: 10, diff --git a/cointop/size.go b/cointop/size.go index 8b99877..70098c3 100644 --- a/cointop/size.go +++ b/cointop/size.go @@ -24,8 +24,8 @@ func (ct *Cointop) height() int { return h } -// viewWidth returns view width -func (ct *Cointop) viewWidth(view string) int { +// ViewWidth returns view width +func (ct *Cointop) ViewWidth(view string) int { ct.debuglog("viewWidth()") v, err := ct.g.View(view) if err != nil { diff --git a/cointop/sort.go b/cointop/sort.go index c673737..ca2785e 100644 --- a/cointop/sort.go +++ b/cointop/sort.go @@ -92,14 +92,13 @@ func (ct *Cointop) SortDesc() error { // SortPrevCol sorts the previous column func (ct *Cointop) SortPrevCol() error { ct.debuglog("sortPrevCol()") - nextsortBy := ct.TableColumnOrder[0] i := ct.GetSortColIndex() k := i - 1 if k < 0 { k = 0 } - nextsortBy = ct.TableColumnOrder[k] + nextsortBy := ct.TableColumnOrder[k] ct.Sort(nextsortBy, ct.State.sortDesc, ct.State.coins, true) ct.UpdateTable() return nil @@ -108,7 +107,6 @@ func (ct *Cointop) SortPrevCol() error { // SortNextCol sorts the next column func (ct *Cointop) SortNextCol() error { ct.debuglog("sortNextCol()") - nextsortBy := ct.TableColumnOrder[0] l := len(ct.TableColumnOrder) i := ct.GetSortColIndex() k := i + 1 @@ -116,7 +114,7 @@ func (ct *Cointop) SortNextCol() error { k = l - 1 } - nextsortBy = ct.TableColumnOrder[k] + nextsortBy := ct.TableColumnOrder[k] ct.Sort(nextsortBy, ct.State.sortDesc, ct.State.coins, true) ct.UpdateTable() return nil diff --git a/cointop/statusbar.go b/cointop/statusbar.go index ee98502..d831839 100644 --- a/cointop/statusbar.go +++ b/cointop/statusbar.go @@ -48,7 +48,7 @@ func (ct *Cointop) UpdateStatusbar(s string) error { } else { base := fmt.Sprintf("%s %sChart %sRange %sSearch %sConvert %s %s", helpStr, "[Enter]", "[[ ]]", "[/]", "[C]", favoritesText, portfolioText) str := pad.Right(fmt.Sprintf("%v %sPage %v/%v %s", base, "[← →]", currpage, totalpages, s), ct.width(), " ") - v := fmt.Sprintf("%s", ct.Version()) + v := ct.Version() end := len(str) - len(v) + 2 if end > len(str) { end = len(str) diff --git a/cointop/table.go b/cointop/table.go index 7e8a5e2..601b85e 100644 --- a/cointop/table.go +++ b/cointop/table.go @@ -2,7 +2,6 @@ package cointop import ( "fmt" - "math" "net/url" "strings" @@ -118,7 +117,7 @@ func (ct *Cointop) GetTableCoinsSlice() []*Coin { start = 0 } if end >= size-1 { - start = int(math.Floor(float64(start/100)) * 100) + start = int(float64(start/100) * 100) end = size - 1 } if start < 0 { diff --git a/cointop/update.go b/cointop/update.go index 9b08b11..b97e8fd 100644 --- a/cointop/update.go +++ b/cointop/update.go @@ -1,14 +1,12 @@ package cointop import ( - "fmt" - "github.com/miguelmota/gocui" ) // UpdateUI takes a callback which updates the view func (ct *Cointop) UpdateUI(f func() error) { - ct.debuglog(fmt.Sprintf("UpdateUI()")) + ct.debuglog("UpdateUI()") if ct.g == nil { return diff --git a/pkg/api/impl/coingecko/coingecko.go b/pkg/api/impl/coingecko/coingecko.go index 33aa12b..7c3d64a 100644 --- a/pkg/api/impl/coingecko/coingecko.go +++ b/pkg/api/impl/coingecko/coingecko.go @@ -14,10 +14,10 @@ import ( ) // ErrPingFailed is the error for when pinging the API fails -var ErrPingFailed = errors.New("Failed to ping") +var ErrPingFailed = errors.New("failed to ping") // ErrNotFound is the error when the target is not found -var ErrNotFound = errors.New("Not found") +var ErrNotFound = errors.New("not found") // Service service type Service struct { diff --git a/pkg/api/impl/coinmarketcap/coinmarketcap.go b/pkg/api/impl/coinmarketcap/coinmarketcap.go index cb855a8..d6b7ed9 100644 --- a/pkg/api/impl/coinmarketcap/coinmarketcap.go +++ b/pkg/api/impl/coinmarketcap/coinmarketcap.go @@ -14,10 +14,10 @@ import ( ) // ErrQuoteNotFound is the error for when a quote is not found -var ErrQuoteNotFound = errors.New("Quote not found") +var ErrQuoteNotFound = errors.New("quote not found") // ErrPingFailed is the error for when pinging the API fails -var ErrPingFailed = errors.New("Failed to ping") +var ErrPingFailed = errors.New("failed to ping") // Service service type Service struct {