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

@@ -49,11 +49,11 @@ func (i *ItBit) GetTicker(ctx context.Context, currencyPair string) (Ticker, err
// GetOrderbook returns full order book for the specified market.
// currencyPair - example "XBTUSD" "XBTSGD" "XBTEUR"
func (i *ItBit) GetOrderbook(ctx context.Context, currencyPair string) (OrderbookResponse, error) {
func (i *ItBit) GetOrderbook(ctx context.Context, currencyPair string) (*OrderbookResponse, error) {
response := OrderbookResponse{}
path := fmt.Sprintf("/%s/%s/%s", itbitMarkets, currencyPair, itbitOrderbook)
return response, i.SendHTTPRequest(ctx, exchange.RestSpot, path, &response)
return &response, i.SendHTTPRequest(ctx, exchange.RestSpot, path, &response)
}
// GetTradeHistory returns recent trades for a specified market.

View File

@@ -221,9 +221,10 @@ func (i *ItBit) UpdateOrderbook(ctx context.Context, p currency.Pair, assetType
orderbookNew, err := i.GetOrderbook(ctx, fpair.String())
if err != nil {
return nil, err
return book, err
}
book.Bids = make(orderbook.Items, len(orderbookNew.Bids))
for x := range orderbookNew.Bids {
var price, amount float64
price, err = strconv.ParseFloat(orderbookNew.Bids[x][0], 64)
@@ -234,13 +235,13 @@ func (i *ItBit) UpdateOrderbook(ctx context.Context, p currency.Pair, assetType
if err != nil {
return book, err
}
book.Bids = append(book.Bids,
orderbook.Item{
Amount: amount,
Price: price,
})
book.Bids[x] = orderbook.Item{
Amount: amount,
Price: price,
}
}
book.Asks = make(orderbook.Items, len(orderbookNew.Asks))
for x := range orderbookNew.Asks {
var price, amount float64
price, err = strconv.ParseFloat(orderbookNew.Asks[x][0], 64)
@@ -251,11 +252,10 @@ func (i *ItBit) UpdateOrderbook(ctx context.Context, p currency.Pair, assetType
if err != nil {
return book, err
}
book.Asks = append(book.Asks,
orderbook.Item{
Amount: amount,
Price: price,
})
book.Asks[x] = orderbook.Item{
Amount: amount,
Price: price,
}
}
err = book.Process()
if err != nil {
@@ -288,7 +288,7 @@ func (i *ItBit) UpdateAccountInfo(ctx context.Context, assetType asset.Item) (ac
}
}
var fullBalance []account.Balance
fullBalance := make([]account.Balance, 0, len(amounts))
for key := range amounts {
fullBalance = append(fullBalance, account.Balance{
CurrencyName: currency.NewCode(key),
@@ -343,9 +343,9 @@ func (i *ItBit) GetRecentTrades(ctx context.Context, p currency.Pair, assetType
if err != nil {
return nil, err
}
var resp []trade.Data
resp := make([]trade.Data, len(tradeData.RecentTrades))
for x := range tradeData.RecentTrades {
resp = append(resp, trade.Data{
resp[x] = trade.Data{
Exchange: i.Name,
TID: tradeData.RecentTrades[x].MatchNumber,
CurrencyPair: p,
@@ -353,7 +353,7 @@ func (i *ItBit) GetRecentTrades(ctx context.Context, p currency.Pair, assetType
Price: tradeData.RecentTrades[x].Price,
Amount: tradeData.RecentTrades[x].Amount,
Timestamp: tradeData.RecentTrades[x].Timestamp,
})
}
}
err = i.AddTradesToBuffer(resp...)
@@ -547,7 +547,7 @@ func (i *ItBit) GetActiveOrders(ctx context.Context, req *order.GetOrdersRequest
return nil, err
}
var orders []order.Detail
orders := make([]order.Detail, 0, len(allOrders))
for j := range allOrders {
var symbol currency.Pair
symbol, err := currency.NewPairDelimiter(allOrders[j].Instrument,
@@ -611,7 +611,7 @@ func (i *ItBit) GetOrderHistory(ctx context.Context, req *order.GetOrdersRequest
return nil, err
}
var orders []order.Detail
orders := make([]order.Detail, 0, len(allOrders))
for j := range allOrders {
if allOrders[j].Type == "open" {
continue