fix: ClearSyncMap pass by reference (#195)

pull/194/head^2
Miguel Mota 3 years ago committed by GitHub
parent 9b03adc2bc
commit cfc93c92c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -67,8 +67,8 @@ func (ct *Cointop) GetCoinsTable() *table.Table {
if ct.IsFavoritesVisible() { if ct.IsFavoritesVisible() {
headers = ct.GetFavoritesTableHeaders() headers = ct.GetFavoritesTableHeaders()
} }
ct.ClearSyncMap(ct.State.tableColumnWidths) ct.ClearSyncMap(&ct.State.tableColumnWidths)
ct.ClearSyncMap(ct.State.tableColumnAlignLeft) ct.ClearSyncMap(&ct.State.tableColumnAlignLeft)
for _, coin := range ct.State.coins { for _, coin := range ct.State.coins {
if coin == nil { if coin == nil {
continue continue

@ -78,8 +78,8 @@ func (ct *Cointop) GetPortfolioTable() *table.Table {
t := table.NewTable().SetWidth(maxX) t := table.NewTable().SetWidth(maxX)
var rows [][]*table.RowCell var rows [][]*table.RowCell
headers := ct.GetPortfolioTableHeaders() headers := ct.GetPortfolioTableHeaders()
ct.ClearSyncMap(ct.State.tableColumnWidths) ct.ClearSyncMap(&ct.State.tableColumnWidths)
ct.ClearSyncMap(ct.State.tableColumnAlignLeft) ct.ClearSyncMap(&ct.State.tableColumnAlignLeft)
for _, coin := range ct.State.coins { for _, coin := range ct.State.coins {
leftMargin := 1 leftMargin := 1
rightMargin := 1 rightMargin := 1

@ -48,8 +48,8 @@ func (ct *Cointop) GetPriceAlertsTable() *table.Table {
t := table.NewTable().SetWidth(maxX) t := table.NewTable().SetWidth(maxX)
var rows [][]*table.RowCell var rows [][]*table.RowCell
headers := ct.GetPriceAlertsTableHeaders() headers := ct.GetPriceAlertsTableHeaders()
ct.ClearSyncMap(ct.State.tableColumnWidths) ct.ClearSyncMap(&ct.State.tableColumnWidths)
ct.ClearSyncMap(ct.State.tableColumnAlignLeft) ct.ClearSyncMap(&ct.State.tableColumnAlignLeft)
for _, entry := range ct.State.priceAlerts.Entries { for _, entry := range ct.State.priceAlerts.Entries {
if entry.Expired { if entry.Expired {
continue continue

@ -46,7 +46,7 @@ func TruncateString(value string, maxLen int) string {
} }
// ClearSyncMap clears a sync.Map // ClearSyncMap clears a sync.Map
func (ct *Cointop) ClearSyncMap(syncMap sync.Map) { func (ct *Cointop) ClearSyncMap(syncMap *sync.Map) {
syncMap.Range(func(key interface{}, value interface{}) bool { syncMap.Range(func(key interface{}, value interface{}) bool {
syncMap.Delete(key) syncMap.Delete(key)
return true return true

Loading…
Cancel
Save