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

@@ -64,7 +64,7 @@ func (b *Bithumb) GetTradablePairs(ctx context.Context) ([]string, error) {
return nil, err
}
var currencies []string
currencies := make([]string, 0, len(result))
for x := range result {
currencies = append(currencies, x)
}
@@ -703,7 +703,7 @@ func (b *Bithumb) FetchExchangeLimits(ctx context.Context) ([]order.MinMaxLevel,
return nil, err
}
var limits []order.MinMaxLevel
limits := make([]order.MinMaxLevel, 0, len(ticks))
for code, data := range ticks {
c := currency.NewCode(code)
cp := currency.NewPair(c, currency.KRW)

View File

@@ -73,8 +73,7 @@ func TestWsHandleData(t *testing.T) {
}
handled := <-dummy.Websocket.DataHandler
_, ok := handled.(*ticker.Price)
if !ok {
if _, ok := handled.(*ticker.Price); !ok {
t.Fatal("unexpected value")
}

View File

@@ -336,20 +336,20 @@ func (b *Bithumb) UpdateOrderbook(ctx context.Context, p currency.Pair, assetTyp
return book, err
}
book.Bids = make(orderbook.Items, len(orderbookNew.Data.Bids))
for i := range orderbookNew.Data.Bids {
book.Bids = append(book.Bids,
orderbook.Item{
Amount: orderbookNew.Data.Bids[i].Quantity,
Price: orderbookNew.Data.Bids[i].Price,
})
book.Bids[i] = orderbook.Item{
Amount: orderbookNew.Data.Bids[i].Quantity,
Price: orderbookNew.Data.Bids[i].Price,
}
}
book.Asks = make(orderbook.Items, len(orderbookNew.Data.Asks))
for i := range orderbookNew.Data.Asks {
book.Asks = append(book.Asks,
orderbook.Item{
Amount: orderbookNew.Data.Asks[i].Quantity,
Price: orderbookNew.Data.Asks[i].Price,
})
book.Asks[i] = orderbook.Item{
Amount: orderbookNew.Data.Asks[i].Quantity,
Price: orderbookNew.Data.Asks[i].Price,
}
}
err = book.Process()
@@ -368,7 +368,7 @@ func (b *Bithumb) UpdateAccountInfo(ctx context.Context, assetType asset.Item) (
return info, err
}
var exchangeBalances []account.Balance
exchangeBalances := make([]account.Balance, 0, len(bal.Total))
for key, totalAmount := range bal.Total {
hold, ok := bal.InUse[key]
if !ok {
@@ -435,7 +435,7 @@ func (b *Bithumb) GetRecentTrades(ctx context.Context, p currency.Pair, assetTyp
if err != nil {
return nil, err
}
var resp []trade.Data
resp := make([]trade.Data, len(tradeData.Data))
for i := range tradeData.Data {
var side order.Side
side, err = order.StringToOrderSide(tradeData.Data[i].Type)
@@ -447,7 +447,7 @@ func (b *Bithumb) GetRecentTrades(ctx context.Context, p currency.Pair, assetTyp
if err != nil {
return nil, err
}
resp = append(resp, trade.Data{
resp[i] = trade.Data{
Exchange: b.Name,
CurrencyPair: p,
AssetType: assetType,
@@ -455,7 +455,7 @@ func (b *Bithumb) GetRecentTrades(ctx context.Context, p currency.Pair, assetTyp
Price: tradeData.Data[i].Price,
Amount: tradeData.Data[i].UnitsTraded,
Timestamp: t,
})
}
}
err = b.AddTradesToBuffer(resp...)

View File

@@ -26,7 +26,8 @@ const (
)
func (b *Bithumb) processBooks(updates *WsOrderbooks) error {
var bids, asks []orderbook.Item
bids := make([]orderbook.Item, 0, len(updates.List))
asks := make([]orderbook.Item, 0, len(updates.List))
for x := range updates.List {
i := orderbook.Item{Price: updates.List[x].Price, Amount: updates.List[x].Quantity}
if updates.List[x].OrderSide == "bid" {
@@ -426,17 +427,19 @@ func (b *Bithumb) SeedLocalCache(ctx context.Context, p currency.Pair) error {
// SeedLocalCacheWithBook seeds the local orderbook cache
func (b *Bithumb) SeedLocalCacheWithBook(p currency.Pair, o *Orderbook) error {
var newOrderBook orderbook.Base
newOrderBook.Bids = make(orderbook.Items, len(o.Data.Bids))
for i := range o.Data.Bids {
newOrderBook.Bids = append(newOrderBook.Bids, orderbook.Item{
newOrderBook.Bids[i] = orderbook.Item{
Amount: o.Data.Bids[i].Quantity,
Price: o.Data.Bids[i].Price,
})
}
}
newOrderBook.Asks = make(orderbook.Items, len(o.Data.Asks))
for i := range o.Data.Asks {
newOrderBook.Asks = append(newOrderBook.Asks, orderbook.Item{
newOrderBook.Asks[i] = orderbook.Item{
Amount: o.Data.Asks[i].Quantity,
Price: o.Data.Asks[i].Price,
})
}
}
newOrderBook.Pair = p