CI: Fix golangci-lint linter issues, add prealloc linter and bump version depends for Go 1.18 (#915)

* Bump CI versions

* Specifically set go version as 1.17.x bumps it to 1.18

* Another

* Adjust AppVeyor

* Part 1 of linter issues

* Part 2

* Fix various linters and improvements

* Part 3

* Finishing touches

* Tests and EqualFold

* Fix nitterinos plus bonus requester jobs bump for exchanges with large number of tests

* Fix nitterinos and bump golangci-lint timeout for AppVeyor

* Address nits, ensure all books are returned on err due to syncer regression

* Fix the wiggins

* Fix duplication

* Fix nitterinos
This commit is contained in:
Adrian Gallagher
2022-04-20 13:45:15 +10:00
committed by GitHub
parent c48e5ea90a
commit 9a4eb9de84
216 changed files with 3493 additions and 2424 deletions

View File

@@ -173,7 +173,7 @@ func (e *EXMO) FetchTradablePairs(ctx context.Context, asset asset.Item) ([]stri
return nil, err
}
var currencies []string
currencies := make([]string, 0, len(pairs))
for x := range pairs {
currencies = append(currencies, x)
}
@@ -298,6 +298,7 @@ func (e *EXMO) UpdateOrderbook(ctx context.Context, p currency.Pair, assetType a
continue
}
book.Asks = make(orderbook.Items, len(data.Ask))
for y := range data.Ask {
var price, amount float64
price, err = strconv.ParseFloat(data.Ask[y][0], 64)
@@ -310,12 +311,13 @@ func (e *EXMO) UpdateOrderbook(ctx context.Context, p currency.Pair, assetType a
return book, err
}
book.Asks = append(book.Asks, orderbook.Item{
book.Asks[y] = orderbook.Item{
Price: price,
Amount: amount,
})
}
}
book.Bids = make(orderbook.Items, len(data.Bid))
for y := range data.Bid {
var price, amount float64
price, err = strconv.ParseFloat(data.Bid[y][0], 64)
@@ -328,10 +330,10 @@ func (e *EXMO) UpdateOrderbook(ctx context.Context, p currency.Pair, assetType a
return book, err
}
book.Bids = append(book.Bids, orderbook.Item{
book.Bids[y] = orderbook.Item{
Price: price,
Amount: amount,
})
}
}
err = book.Process()
@@ -352,7 +354,7 @@ func (e *EXMO) UpdateAccountInfo(ctx context.Context, assetType asset.Item) (acc
return response, err
}
var currencies []account.Balance
currencies := make([]account.Balance, 0, len(result.Balances))
for x, y := range result.Balances {
var exchangeCurrency account.Balance
exchangeCurrency.CurrencyName = currency.NewCode(x)
@@ -421,15 +423,16 @@ func (e *EXMO) GetRecentTrades(ctx context.Context, p currency.Pair, assetType a
if err != nil {
return nil, err
}
var resp []trade.Data
mapData := tradeData[p.String()]
resp := make([]trade.Data, len(mapData))
for i := range mapData {
var side order.Side
side, err = order.StringToOrderSide(mapData[i].Type)
if err != nil {
return nil, err
}
resp = append(resp, trade.Data{
resp[i] = trade.Data{
Exchange: e.Name,
TID: strconv.FormatInt(mapData[i].TradeID, 10),
CurrencyPair: p,
@@ -438,7 +441,7 @@ func (e *EXMO) GetRecentTrades(ctx context.Context, p currency.Pair, assetType a
Price: mapData[i].Price,
Amount: mapData[i].Quantity,
Timestamp: time.Unix(mapData[i].Date, 0),
})
}
}
err = e.AddTradesToBuffer(resp...)
@@ -638,7 +641,7 @@ func (e *EXMO) GetActiveOrders(ctx context.Context, req *order.GetOrdersRequest)
return nil, err
}
var orders []order.Detail
orders := make([]order.Detail, 0, len(resp))
for i := range resp {
var symbol currency.Pair
symbol, err = currency.NewPairDelimiter(resp[i].Pair, "_")
@@ -690,7 +693,7 @@ func (e *EXMO) GetOrderHistory(ctx context.Context, req *order.GetOrdersRequest)
}
}
var orders []order.Detail
orders := make([]order.Detail, len(allTrades))
for i := range allTrades {
pair, err := currency.NewPairDelimiter(allTrades[i].Pair, "_")
if err != nil {
@@ -711,7 +714,7 @@ func (e *EXMO) GetOrderHistory(ctx context.Context, req *order.GetOrdersRequest)
Pair: pair,
}
detail.InferCostsAndTimes()
orders = append(orders, detail)
orders[i] = detail
}
order.FilterOrdersByTimeRange(&orders, req.StartTime, req.EndTime)