From 7e08e483fbaa76f14e31d76e3c2fe3af237aba4c Mon Sep 17 00:00:00 2001 From: Adrian Gallagher Date: Fri, 3 Feb 2023 15:56:59 +1100 Subject: [PATCH] CI: Bump go version, linters and fix minor issues (#1130) * CI: Bump go version, linters and fix minor issues * Bump version, fix loop variables * Revert * Rid TODOs now that 1.51 has been released --- .appveyor.yml | 2 +- .github/workflows/linter.yml | 4 ++-- .github/workflows/proto-lint.yml | 2 +- .github/workflows/tests.yml | 2 +- .gitignore | 3 +++ .golangci.yml | 22 +++++++++++------ Dockerfile | 2 +- Makefile | 2 +- backtester/common/common_test.go | 2 ++ common/crypto/crypto.go | 5 ++-- communications/base/base.go | 2 +- communications/smsglobal/smsglobal.go | 2 +- config/config_test.go | 2 +- currency/coinmarketcap/coinmarketcap.go | 6 ++--- engine/helpers.go | 3 +-- engine/helpers_test.go | 2 +- engine/rpcserver.go | 5 +--- exchanges/alphapoint/alphapoint.go | 2 +- exchanges/bitfinex/bitfinex_test.go | 2 +- exchanges/bitmex/bitmex.go | 4 ++-- exchanges/bitmex/bitmex_types.go | 2 +- exchanges/bitstamp/bitstamp.go | 2 +- exchanges/btcmarkets/btcmarkets_wrapper.go | 5 +--- exchanges/coinut/coinut_wrapper.go | 2 -- exchanges/exchange.go | 2 +- exchanges/exchange_test.go | 2 +- exchanges/gemini/gemini.go | 2 +- exchanges/huobi/huobi_futures.go | 2 +- exchanges/huobi/huobi_types.go | 2 +- exchanges/itbit/itbit_wrapper.go | 2 +- exchanges/kline/kline_test.go | 1 - exchanges/kline/technical_analysis.go | 2 +- exchanges/okx/okx_websocket.go | 2 +- exchanges/order/order_test.go | 1 + exchanges/orderbook/orderbook_test.go | 2 -- exchanges/request/request_types.go | 4 ++-- exchanges/stream/buffer/buffer_test.go | 1 - exchanges/stream/websocket.go | 2 +- log/logger_test.go | 28 +++++++++++----------- 39 files changed, 71 insertions(+), 71 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index dcda595c..fa4b4c53 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -55,7 +55,7 @@ before_test: test_script: # test back-end - - go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.48.0 + - go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.0 - '%GOPATH%\bin\golangci-lint.exe run --verbose' - ps: >- if($env:APPVEYOR_SCHEDULED_BUILD -eq 'true') { diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index bd40d8c8..5baf4cc1 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -8,8 +8,8 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: '1.19.x' + go-version: '1.20.x' - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: - version: v1.48.0 + version: v1.51.0 diff --git a/.github/workflows/proto-lint.yml b/.github/workflows/proto-lint.yml index 90cd40f9..f3131a53 100644 --- a/.github/workflows/proto-lint.yml +++ b/.github/workflows/proto-lint.yml @@ -12,7 +12,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v3 with: - go-version: 1.19.x + go-version: 1.20.x - name: Setup build depends run: | diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c78eb94d..bab8b908 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,7 +1,7 @@ on: [push, pull_request] name: CI env: - GO_VERSION: 1.19.x + GO_VERSION: 1.20.x jobs: backend-psql: name: GoCryptoTrader back-end with PSQL diff --git a/.gitignore b/.gitignore index 9ffa1a8b..0afe8d44 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,10 @@ config.json config.dat node_modules lib + +# VS Code .vscode +tmp/ testdata/dump testdata/preengine_config.json diff --git a/.golangci.yml b/.golangci.yml index 4264bc95..35ed4ffc 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,5 +1,5 @@ run: - timeout: 8m + timeout: 10m issues-exit-code: 1 tests: true skip-dirs: @@ -12,7 +12,6 @@ linters: disable-all: true enable: # defaults -# - deadcode - errcheck - gosimple - govet @@ -20,7 +19,6 @@ linters: - staticcheck - typecheck # - unused -# - varcheck # disabled by default linters # - asasalint @@ -30,23 +28,27 @@ linters: - containedctx # - contextcheck # - cyclop +# - deadcode // abandoned by its owner, replaced by unused - decorder - depguard - dogsled # - dupl + - dupword - durationcheck - errchkjson - errname # - errorlint - execinquery # - exhaustive -# - exhaustivestruct // abandoned by its owner, replaced with exhaustruct +# - exhaustivestruct // abandoned by its owner, replaced by exhaustruct # - exhaustruct - exportloopref # - forbidigo - forcetypeassert # - funlen - gci +# - ginkgolinter + - gocheckcompilerdirectives # - gochecknoglobals # - gochecknoinits # - gocognit @@ -69,13 +71,16 @@ linters: - grouper # - ifshort // deprecated by its owner # - importas +# - interfacebloat # - interfacer // deprecated by its owner # - ireturn # - lll +# - loggercheck # - maintidx - makezero -# - maligned +# - maligned // deprecated by its owner, replaced by govet 'fieldalignment' - misspell +# - musttag - nakedret # - nestif - nilerr @@ -84,26 +89,29 @@ linters: - noctx - nolintlint # - nonamedreturns -# - nosnakecase +# - nosnakecase // deprecated by its owner, replaced by revive 'var-naming' - nosprintfhostport # - paralleltest - prealloc - predeclared # - promlinter + - reassign - revive - rowserrcheck # - scopelint // deprecated since v1.39.0, replaced by exportloopref - sqlclosecheck - - structcheck +# - structcheck // abandoned by its owner, replaced by unused - stylecheck # - tagliatelle - tenv + - testableexamples # - testpackage - thelper - tparallel - unconvert - unparam - usestdlibvars +# - varcheck // abandoned by its owner, replaced by unused # - varnamelen - wastedassign - whitespace diff --git a/Dockerfile b/Dockerfile index 6cbbec70..e6a6b421 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.19 as build +FROM golang:1.20 as build WORKDIR /go/src/github.com/thrasher-corp/gocryptotrader COPY . . RUN GO111MODULE=on go mod vendor diff --git a/Makefile b/Makefile index 3dcf161a..9d2880fa 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ LDFLAGS = -ldflags "-w -s" GCTPKG = github.com/thrasher-corp/gocryptotrader -LINTPKG = github.com/golangci/golangci-lint/cmd/golangci-lint@v1.48.0 +LINTPKG = github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.0 LINTBIN = $(GOPATH)/bin/golangci-lint GCTLISTENPORT=9050 GCTPROFILERLISTENPORT=8085 diff --git a/backtester/common/common_test.go b/backtester/common/common_test.go index ecf2b369..220bba89 100644 --- a/backtester/common/common_test.go +++ b/backtester/common/common_test.go @@ -89,6 +89,7 @@ func TestCanTransact(t *testing.T) { expected: false, }, } { + ti := ti t.Run(ti.side.String(), func(t *testing.T) { t.Parallel() if CanTransact(ti.side) != ti.expected { @@ -123,6 +124,7 @@ func TestDataTypeConversion(t *testing.T) { expectErr: true, }, } { + ti := ti t.Run(ti.title, func(t *testing.T) { t.Parallel() got, err := DataTypeToInt(ti.dataType) diff --git a/common/crypto/crypto.go b/common/crypto/crypto.go index 44a1e599..f0188e57 100644 --- a/common/crypto/crypto.go +++ b/common/crypto/crypto.go @@ -1,11 +1,10 @@ package crypto -//nolint:gosec // md5/sha1 hash functions used by some exchanges import ( "crypto/hmac" - "crypto/md5" + "crypto/md5" //nolint:gosec // Used for exchanges "crypto/rand" - "crypto/sha1" + "crypto/sha1" //nolint:gosec // Used for exchanges "crypto/sha256" "crypto/sha512" "encoding/base64" diff --git a/communications/base/base.go b/communications/base/base.go index 330ff284..7ba9fbfe 100644 --- a/communications/base/base.go +++ b/communications/base/base.go @@ -62,7 +62,7 @@ type CommunicationsConfig struct { TelegramConfig TelegramConfig `json:"telegram"` } -// IsAnyEnabled returns whether or any any comms relayers +// IsAnyEnabled returns whether any comms relayers // are enabled func (c *CommunicationsConfig) IsAnyEnabled() bool { if c.SMSGlobalConfig.Enabled || diff --git a/communications/smsglobal/smsglobal.go b/communications/smsglobal/smsglobal.go index 463d0277..b03b00cd 100644 --- a/communications/smsglobal/smsglobal.go +++ b/communications/smsglobal/smsglobal.go @@ -33,7 +33,7 @@ type SMSGlobal struct { } // Setup takes in a SMSGlobal configuration, sets username, password and -// and recipient list +// recipient list func (s *SMSGlobal) Setup(cfg *base.CommunicationsConfig) { s.Name = cfg.SMSGlobalConfig.Name s.Enabled = cfg.SMSGlobalConfig.Enabled diff --git a/config/config_test.go b/config/config_test.go index f703c481..e78e8636 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -1386,7 +1386,7 @@ func TestCheckExchangeConfigValues(t *testing.T) { t.Error("unexpected values") } - // Test feature and endpoint migrations migrations + // Test feature and endpoint migrations cfg.Exchanges[0].Features = nil cfg.Exchanges[0].SupportsAutoPairUpdates = convert.BoolPtr(true) cfg.Exchanges[0].Websocket = convert.BoolPtr(true) diff --git a/currency/coinmarketcap/coinmarketcap.go b/currency/coinmarketcap/coinmarketcap.go index 3d837744..05f896a7 100644 --- a/currency/coinmarketcap/coinmarketcap.go +++ b/currency/coinmarketcap/coinmarketcap.go @@ -127,7 +127,7 @@ func (c *Coinmarketcap) GetCryptocurrencyHistoricalListings() ([]CryptocurrencyH // NOTE unreachable code but will be utilised at a later date // resp := struct { // Data []CryptocurrencyHistoricalListings `json:"data"` - // Status Status `json:"status"` + // ServerStatus Status `json:"status"` // }{} //nolint:gocritic // unused code, used as example @@ -143,8 +143,8 @@ func (c *Coinmarketcap) GetCryptocurrencyHistoricalListings() ([]CryptocurrencyH // } //nolint:gocritic // unused code, used as example - // if resp.Status.ErrorCode != 0 { - // return resp.Data, errors.New(resp.Status.ErrorMessage) + // if resp.ServerStatus.ErrorCode != 0 { + // return resp.Data, errors.New(resp.ServerStatus.ErrorMessage) // } //nolint:gocritic // unused code, used as example diff --git a/engine/helpers.go b/engine/helpers.go index 29c41e8b..1b8a420b 100644 --- a/engine/helpers.go +++ b/engine/helpers.go @@ -569,8 +569,7 @@ func (bot *Engine) GetSpecificTicker(ctx context.Context, p currency.Pair, excha } // GetCollatedExchangeAccountInfoByCoin collates individual exchange account -// information and turns into into a map string of -// exchange.AccountCurrencyInfo +// information and turns it into a map string of exchange.AccountCurrencyInfo func GetCollatedExchangeAccountInfoByCoin(accounts []account.Holdings) map[currency.Code]account.Balance { result := make(map[currency.Code]account.Balance) for x := range accounts { diff --git a/engine/helpers_test.go b/engine/helpers_test.go index c1ee38cf..d6028aa8 100644 --- a/engine/helpers_test.go +++ b/engine/helpers_test.go @@ -570,7 +570,7 @@ func TestIsRelatablePairs(t *testing.T) { t.Fatal(err) } - // Test relationl crypto pairs with with similar names + // Test relationl crypto pairs with similar names result = IsRelatablePairs(xbtltc, btcltc, false) if !result { t.Fatal("Unexpected result") diff --git a/engine/rpcserver.go b/engine/rpcserver.go index 4e5bec0a..5dcc29b2 100644 --- a/engine/rpcserver.go +++ b/engine/rpcserver.go @@ -2542,10 +2542,7 @@ func fillMissingCandlesWithStoredTrades(startTime, endTime time.Time, klineItem if len(tradeCandles.Candles) == 0 { continue } - - for i := range tradeCandles.Candles { - response.Candles = append(response.Candles, tradeCandles.Candles[i]) - } + response.Candles = append(response.Candles, tradeCandles.Candles...) for i := range response.Candles { log.Infof(log.GRPCSys, diff --git a/exchanges/alphapoint/alphapoint.go b/exchanges/alphapoint/alphapoint.go index 0df11b62..74cfd21c 100644 --- a/exchanges/alphapoint/alphapoint.go +++ b/exchanges/alphapoint/alphapoint.go @@ -467,7 +467,7 @@ func (a *Alphapoint) CancelExistingOrder(ctx context.Context, orderID int64, oms return response.CancelOrderID, nil } -// CancelAllExistingOrders cancels all open orders by symbol +// CancelAllExistingOrders cancels all open orders by symbol. // symbol - Instrument code (ex: “BTCUSD”) func (a *Alphapoint) CancelAllExistingOrders(ctx context.Context, omsid string) error { req := make(map[string]interface{}) diff --git a/exchanges/bitfinex/bitfinex_test.go b/exchanges/bitfinex/bitfinex_test.go index 1aee6305..c87de6f8 100644 --- a/exchanges/bitfinex/bitfinex_test.go +++ b/exchanges/bitfinex/bitfinex_test.go @@ -1745,7 +1745,7 @@ func TestReOrderbyID(t *testing.T) { func TestPopulateAcceptableMethods(t *testing.T) { t.Parallel() if acceptableMethods.loaded() { - // we may have have been loaded from another test, so reset + // we may have been loaded from another test, so reset acceptableMethods.m.Lock() acceptableMethods.a = make(map[string][]string) acceptableMethods.m.Unlock() diff --git a/exchanges/bitmex/bitmex.go b/exchanges/bitmex/bitmex.go index b167f68e..b100285a 100644 --- a/exchanges/bitmex/bitmex.go +++ b/exchanges/bitmex/bitmex.go @@ -189,7 +189,7 @@ func (b *Bitmex) SendTrollboxMessage(ctx context.Context, params ChatSendParams) &messages) } -// GetTrollboxChannels the channels from the the bitmex trollbox +// GetTrollboxChannels the channels from the bitmex trollbox func (b *Bitmex) GetTrollboxChannels(ctx context.Context) ([]ChatChannel, error) { var channels []ChatChannel @@ -198,7 +198,7 @@ func (b *Bitmex) GetTrollboxChannels(ctx context.Context) ([]ChatChannel, error) &channels) } -// GetTrollboxConnectedUsers the channels from the the bitmex trollbox +// GetTrollboxConnectedUsers the channels from the bitmex trollbox func (b *Bitmex) GetTrollboxConnectedUsers(ctx context.Context) (ConnectedUsers, error) { var users ConnectedUsers diff --git a/exchanges/bitmex/bitmex_types.go b/exchanges/bitmex/bitmex_types.go index 060ac842..79c0cff4 100644 --- a/exchanges/bitmex/bitmex_types.go +++ b/exchanges/bitmex/bitmex_types.go @@ -241,7 +241,7 @@ type IndexComposite struct { Weight float64 `json:"weight"` } -// Insurance Insurance Fund Data +// Insurance stores insurance fund data type Insurance struct { Currency string `json:"currency"` Timestamp time.Time `json:"timestamp"` diff --git a/exchanges/bitstamp/bitstamp.go b/exchanges/bitstamp/bitstamp.go index 4008863a..a2b0481d 100644 --- a/exchanges/bitstamp/bitstamp.go +++ b/exchanges/bitstamp/bitstamp.go @@ -483,7 +483,7 @@ func (b *Bitstamp) OpenInternationalBankWithdrawal(ctx context.Context, amount f return resp, b.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, bitstampAPIOpenWithdrawal, true, req, &resp) } -// GetCryptoDepositAddress returns a depositing address by crypto +// GetCryptoDepositAddress returns a depositing address by crypto. // crypto - example "btc", "ltc", "eth", "xrp" or "bch" func (b *Bitstamp) GetCryptoDepositAddress(ctx context.Context, crypto currency.Code) (*DepositAddress, error) { path := crypto.Lower().String() + "_address" diff --git a/exchanges/btcmarkets/btcmarkets_wrapper.go b/exchanges/btcmarkets/btcmarkets_wrapper.go index 5e67135c..9a5be88b 100644 --- a/exchanges/btcmarkets/btcmarkets_wrapper.go +++ b/exchanges/btcmarkets/btcmarkets_wrapper.go @@ -826,10 +826,7 @@ func (b *BTCMarkets) GetActiveOrders(ctx context.Context, req *order.GetOrdersRe if err != nil { return nil, err } - for a := range allPairs { - req.Pairs = append(req.Pairs, - allPairs[a]) - } + req.Pairs = append(req.Pairs, allPairs...) } var resp []order.Detail diff --git a/exchanges/coinut/coinut_wrapper.go b/exchanges/coinut/coinut_wrapper.go index c069aad2..88499ad4 100644 --- a/exchanges/coinut/coinut_wrapper.go +++ b/exchanges/coinut/coinut_wrapper.go @@ -4,7 +4,6 @@ import ( "context" "errors" "fmt" - "math/rand" "sort" "strconv" "strings" @@ -131,7 +130,6 @@ func (c *COINUT) SetDefaults() { c.WebsocketResponseMaxLimit = exchange.DefaultWebsocketResponseMaxLimit c.WebsocketResponseCheckTimeout = exchange.DefaultWebsocketResponseCheckTimeout c.WebsocketOrderbookBufferLimit = exchange.DefaultWebsocketOrderbookBufferLimit - rand.Seed(time.Now().UnixNano()) } // Setup sets the current exchange configuration diff --git a/exchanges/exchange.go b/exchanges/exchange.go index 1b900e64..8fbf537c 100644 --- a/exchanges/exchange.go +++ b/exchanges/exchange.go @@ -1014,7 +1014,7 @@ func (b *Base) StoreAssetPairFormat(a asset.Item, f currency.PairStore) error { } // SetGlobalPairsManager sets defined asset and pairs management system with -// with global formatting +// global formatting func (b *Base) SetGlobalPairsManager(request, config *currency.PairFormat, assets ...asset.Item) error { if request == nil { return fmt.Errorf("%s cannot set pairs manager, request pair format not provided", diff --git a/exchanges/exchange_test.go b/exchanges/exchange_test.go index 60409917..ba7aed67 100644 --- a/exchanges/exchange_test.go +++ b/exchanges/exchange_test.go @@ -173,7 +173,7 @@ func TestSetDefaultEndpoints(t *testing.T) { EdgeCase1: "", }) if err != nil { - t.Errorf("expecting a warning due due to invalid url val but got an error: %v", err) + t.Errorf("expecting a warning due to invalid url value but got an error: %v", err) } } diff --git a/exchanges/gemini/gemini.go b/exchanges/gemini/gemini.go index cf606e0a..85b8cdc3 100644 --- a/exchanges/gemini/gemini.go +++ b/exchanges/gemini/gemini.go @@ -46,7 +46,7 @@ const ( // Gemini is the overarching type across the Gemini package, create multiple // instances with differing APIkeys for segregation of roles for authenticated // requests & sessions by appending new sessions to the Session map using -// AddSession, if sandbox test is needed append a new session with with the same +// AddSession. If sandbox test is needed, append a new session with the same // API keys and change the IsSandbox variable to true. type Gemini struct { exchange.Base diff --git a/exchanges/huobi/huobi_futures.go b/exchanges/huobi/huobi_futures.go index f106fd17..86cffde5 100644 --- a/exchanges/huobi/huobi_futures.go +++ b/exchanges/huobi/huobi_futures.go @@ -905,7 +905,7 @@ func (h *HUOBI) FGetOpenOrders(ctx context.Context, symbol currency.Code, pageIn return resp, h.FuturesAuthenticatedHTTPRequest(ctx, exchange.RestFutures, http.MethodPost, fQueryOpenOrders, nil, req, &resp) } -// FGetOrderHistory gets order order history for futures +// FGetOrderHistory gets order history for futures func (h *HUOBI) FGetOrderHistory(ctx context.Context, contractCode currency.Pair, symbol, tradeType, reqType, orderType string, status []order.Status, createDate, pageIndex, pageSize int64) (FOrderHistoryData, error) { var resp FOrderHistoryData req := make(map[string]interface{}) diff --git a/exchanges/huobi/huobi_types.go b/exchanges/huobi/huobi_types.go index a62fc97d..dabe1a12 100644 --- a/exchanges/huobi/huobi_types.go +++ b/exchanges/huobi/huobi_types.go @@ -568,7 +568,7 @@ type Trade struct { Timestamp int64 `json:"ts"` } -// TradeHistory stores the the trade history data +// TradeHistory stores the trade history data type TradeHistory struct { ID int64 `json:"id"` Timestamp int64 `json:"ts"` diff --git a/exchanges/itbit/itbit_wrapper.go b/exchanges/itbit/itbit_wrapper.go index 1c681728..29cc76ef 100644 --- a/exchanges/itbit/itbit_wrapper.go +++ b/exchanges/itbit/itbit_wrapper.go @@ -487,7 +487,7 @@ func (i *ItBit) GetOrderInfo(ctx context.Context, orderID string, pair currency. // GetDepositAddress returns a deposit address for a specified currency // NOTE: This has not been implemented due to the fact you need to generate a -// a specific wallet ID and they restrict the amount of deposit address you can +// specific wallet ID and they restrict the amount of deposit addresses you can // request limiting them to 2. func (i *ItBit) GetDepositAddress(_ context.Context, _ currency.Code, _, _ string) (*deposit.Address, error) { return nil, common.ErrNotYetImplemented diff --git a/exchanges/kline/kline_test.go b/exchanges/kline/kline_test.go index 113140f7..fa64ca71 100644 --- a/exchanges/kline/kline_test.go +++ b/exchanges/kline/kline_test.go @@ -96,7 +96,6 @@ func TestCreateKline(t *testing.T) { tradeTotal := 24000 var trades []order.TradeHistory - rand.Seed(time.Now().Unix()) execution := time.Now() for i := 0; i < tradeTotal; i++ { price, rndTime := 1000+float64(rand.Intn(1000)), rand.Intn(10) //nolint:gosec // no need to import crypo/rand for testing diff --git a/exchanges/kline/technical_analysis.go b/exchanges/kline/technical_analysis.go index 91c2f374..10227b62 100644 --- a/exchanges/kline/technical_analysis.go +++ b/exchanges/kline/technical_analysis.go @@ -333,7 +333,7 @@ func (k *Item) GetRelativeStrengthIndexOnClose(period int64) ([]float64, error) return ohlc.GetRelativeStrengthIndex(ohlc.Close, period) } -// GetRelativeStrengthIndex returns the relative strength index from the the +// GetRelativeStrengthIndex returns the relative strength index from the // given price set and period. func (o *OHLC) GetRelativeStrengthIndex(option []float64, period int64) ([]float64, error) { if o == nil { diff --git a/exchanges/okx/okx_websocket.go b/exchanges/okx/okx_websocket.go index 2e434e19..1b845a2e 100644 --- a/exchanges/okx/okx_websocket.go +++ b/exchanges/okx/okx_websocket.go @@ -1958,7 +1958,7 @@ func (ok *Okx) EstimatedDeliveryExercisePriceSubscription(operation string, asse return ok.wsChannelSubscription(operation, okxChannelEstimatedPrice, assetType, pair, true, true, false) } -// MarkPriceSubscription to subscribe or unsubscribe to to "mark-price" to retrieve the mark price. Data will be pushed every 200 ms when the mark price changes, and will be pushed every 10 seconds when the mark price does not change. +// MarkPriceSubscription to subscribe or unsubscribe to the "mark-price" to retrieve the mark price. Data will be pushed every 200 ms when the mark price changes, and will be pushed every 10 seconds when the mark price does not change. func (ok *Okx) MarkPriceSubscription(operation string, assetType asset.Item, pair currency.Pair) error { return ok.wsChannelSubscription(operation, okxChannelMarkPrice, assetType, pair, false, true, false) } diff --git a/exchanges/order/order_test.go b/exchanges/order/order_test.go index cb07e5bb..41e6b45d 100644 --- a/exchanges/order/order_test.go +++ b/exchanges/order/order_test.go @@ -1665,6 +1665,7 @@ func TestIsOrderPlaced(t *testing.T) { } // specific tests for num, tt := range statusTests { + num := num tt := tt t.Run(fmt.Sprintf("TEST CASE: %d", num), func(t *testing.T) { t.Parallel() diff --git a/exchanges/orderbook/orderbook_test.go b/exchanges/orderbook/orderbook_test.go index 0ea9fffc..0d2e2eba 100644 --- a/exchanges/orderbook/orderbook_test.go +++ b/exchanges/orderbook/orderbook_test.go @@ -556,7 +556,6 @@ func TestProcessOrderbook(t *testing.T) { func deployUnorderedSlice() Items { var items []Item - rand.Seed(time.Now().UnixNano()) for i := 0; i < 1000; i++ { items = append(items, Item{Amount: 1, Price: rand.Float64(), ID: rand.Int63()}) //nolint:gosec // Not needed in tests } @@ -593,7 +592,6 @@ func TestSorting(t *testing.T) { } func deploySliceOrdered() Items { - rand.Seed(time.Now().UnixNano()) var items []Item for i := 0; i < 1000; i++ { items = append(items, Item{Amount: 1, Price: float64(i + 1), ID: rand.Int63()}) //nolint:gosec // Not needed in tests diff --git a/exchanges/request/request_types.go b/exchanges/request/request_types.go index c7c42f6e..5e823b58 100644 --- a/exchanges/request/request_types.go +++ b/exchanges/request/request_types.go @@ -70,8 +70,8 @@ type RetryPolicy func(resp *http.Response, err error) (bool, error) type RequesterOption func(*Requester) // Generate defines a closure for functionality outside of the requester to -// to generate new *http.Request on every attempt. This minimizes the chance of -// being outside of receive window if application rate limiting reduces outbound +// generate a new *http.Request on every attempt. This minimizes the chance of +// being outside of the receive window if application rate limiting reduces outbound // requests. type Generate func() (*Item, error) diff --git a/exchanges/stream/buffer/buffer_test.go b/exchanges/stream/buffer/buffer_test.go index 566f1cad..2e85531d 100644 --- a/exchanges/stream/buffer/buffer_test.go +++ b/exchanges/stream/buffer/buffer_test.go @@ -895,7 +895,6 @@ func TestEnsureMultipleUpdatesViaPrice(t *testing.T) { } func deploySliceOrdered(size int) orderbook.Items { - rand.Seed(time.Now().UnixNano()) var items []orderbook.Item for i := 0; i < size; i++ { items = append(items, orderbook.Item{Amount: 1, Price: rand.Float64() + float64(i), ID: rand.Int63()}) //nolint:gosec // Not needed for tests diff --git a/exchanges/stream/websocket.go b/exchanges/stream/websocket.go index 245e6b4e..e43ddbc4 100644 --- a/exchanges/stream/websocket.go +++ b/exchanges/stream/websocket.go @@ -953,7 +953,7 @@ func (w *ChannelSubscription) Equal(s *ChannelSubscription) bool { } // GetSubscriptions returns a copied list of subscriptions -// subscriptions is a private member and cannot be manipulated +// and is a private member that cannot be manipulated func (w *Websocket) GetSubscriptions() []ChannelSubscription { w.subscriptionMutex.Lock() defer w.subscriptionMutex.Unlock() diff --git a/log/logger_test.go b/log/logger_test.go index 6b28dad0..3a87c750 100644 --- a/log/logger_test.go +++ b/log/logger_test.go @@ -347,8 +347,8 @@ func TestStageNewLogEvent(t *testing.T) { fields.output.StageLogEvent(func() string { return "out" }, "header", "SUBLOGGER", " space ", "", false, false) <-w.Finished - if contents := w.Read(); contents != "header space space out\n" { - t.Errorf("received: '%v' but expected: '%v'", contents, "header space space out\n") + if contents := w.Read(); contents != "header space space out\n" { //nolint:dupword // False positive + t.Errorf("received: '%v' but expected: '%v'", contents, "header space space out\n") //nolint:dupword // False positive } } @@ -382,11 +382,11 @@ func TestInfo(t *testing.T) { t.Errorf("received: '%v' but expected: '%v'", contents, "hello") } - Infoln(sl, "hello", "hello") + Infoln(sl, "hello", "goodbye") <-w.Finished contents = w.Read() - if !strings.Contains(contents, "hello hello") { - t.Errorf("received: '%v' but expected: '%v'", contents, "hello hello") + if !strings.Contains(contents, "hello goodbye") { + t.Errorf("received: '%v' but expected: '%v'", contents, "hello goodbye") } _, err = SetLevel("TESTYMCTESTALOTINFO", "") @@ -439,11 +439,11 @@ func TestDebug(t *testing.T) { t.Errorf("received: '%v' but expected: '%v'", contents, "hello") } - Debugln(sl, "hello", "hello") + Debugln(sl, ":sun_with_face:", ":angrysun:") <-w.Finished contents = w.Read() - if !strings.Contains(contents, "hello hello") { - t.Errorf("received: '%v' but expected: '%v'", contents, "hello hello") + if !strings.Contains(contents, ":sun_with_face: :angrysun:") { + t.Errorf("received: '%v' but expected: '%v'", contents, ":sun_with_face: :angrysun:") } _, err = SetLevel("TESTYMCTESTALOTDEBUG", "") @@ -496,11 +496,11 @@ func TestWarn(t *testing.T) { t.Errorf("received: '%v' but expected: '%v'", contents, "hello") } - Warnln(sl, "hello", "hello") + Warnln(sl, "hello", "world") <-w.Finished contents = w.Read() - if !strings.Contains(contents, "hello hello") { - t.Errorf("received: '%v' but expected: '%v'", contents, "hello hello") + if !strings.Contains(contents, "hello world") { + t.Errorf("received: '%v' but expected: '%v'", contents, "hello world") } _, err = SetLevel("TESTYMCTESTALOTWARN", "") @@ -558,11 +558,11 @@ func TestError(t *testing.T) { t.Errorf("received: '%v' but expected: '%v'", contents, "hello") } - Errorln(sl, "hello", "hello") + Errorln(sl, "hello", "goodbye") <-w.Finished contents = w.Read() - if !strings.Contains(contents, "hello hello") { - t.Errorf("received: '%v' but expected: '%v'", contents, "hello hello") + if !strings.Contains(contents, "hello goodbye") { + t.Errorf("received: '%v' but expected: '%v'", contents, "hello goodbye") } _, err = SetLevel("TESTYMCTESTALOTERROR", "")