From e9b3e3d328c5fb502291878f4064a85b9b57d330 Mon Sep 17 00:00:00 2001 From: Adrian Gallagher Date: Mon, 11 Nov 2019 15:15:29 +1100 Subject: [PATCH] Bump golangci-lint and AppVeyor versions now that 1.13.x is supported (#375) --- .appveyor.yml | 4 +- .golangci.yml | 54 ++++++++++--------- Makefile | 2 +- common/common_test.go | 3 -- communications/slack/slack.go | 6 --- communications/slack/slack_test.go | 2 - config/config.go | 2 - currency/code.go | 20 +++---- currency/storage.go | 1 - currency/symbol_test.go | 1 - exchange.go | 1 - exchanges/anx/anx.go | 1 - exchanges/binance/binance_test.go | 1 - exchanges/bitfinex/bitfinex_test.go | 1 - exchanges/bitfinex/bitfinex_websocket.go | 1 - exchanges/bitmex/bitmex_websocket.go | 1 - exchanges/bitmex/bitmex_wrapper.go | 1 - exchanges/bitstamp/bitstamp_wrapper.go | 2 - exchanges/bittrex/bittrex.go | 1 - exchanges/bittrex/bittrex_wrapper.go | 1 - exchanges/btse/btse.go | 1 - exchanges/btse/btse_test.go | 1 - exchanges/btse/btse_wrapper.go | 1 - exchanges/coinbasepro/coinbasepro_test.go | 3 -- exchanges/coinbasepro/coinbasepro_types.go | 2 +- exchanges/coinut/coinut_test.go | 3 -- exchanges/coinut/coinut_websocket.go | 2 - exchanges/coinut/coinut_wrapper.go | 3 -- exchanges/exmo/exmo_test.go | 3 -- exchanges/gemini/gemini.go | 1 - exchanges/hitbtc/hitbtc_types.go | 24 ++++----- exchanges/kraken/kraken.go | 1 - exchanges/lakebtc/lakebtc_wrapper.go | 1 - exchanges/lbank/lbank.go | 1 - exchanges/lbank/lbank_wrapper.go | 1 - .../localbitcoins/localbitcoins_types.go | 12 ++--- .../localbitcoins/localbitcoins_wrapper.go | 1 - exchanges/mock/recording.go | 1 - exchanges/okcoin/okcoin_test.go | 1 - exchanges/okex/okex.go | 1 - exchanges/okex/okex_test.go | 1 - exchanges/okgroup/okgroup.go | 1 - exchanges/okgroup/okgroup_websocket.go | 3 -- exchanges/poloniex/poloniex_types.go | 2 +- exchanges/ticker/ticker_test.go | 1 - exchanges/websocket/wshandler/wshandler.go | 1 - .../websocket/wsorderbook/wsorderbook_test.go | 1 - exchanges/zb/zb_websocket_types.go | 2 +- helpers.go | 2 - main.go | 1 - portfolio/portfolio.go | 1 - portfolio/portfolio_test.go | 1 - restful_router.go | 2 +- restful_server.go | 1 - tools/huobi_auth/main.go | 1 - 55 files changed, 63 insertions(+), 128 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 3aef67cb..03edc788 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -14,7 +14,7 @@ environment: NODEJS_VER: 10.15.3 APPVEYOR_SAVE_CACHE_ON_ERROR: true -stack: go 1.12.3 +stack: go 1.13.x install: - set Path=C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;%Path% @@ -28,7 +28,7 @@ before_test: test_script: # test back-end - - go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.18.0 + - go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.20.1 - '%GOPATH%\bin\golangci-lint.exe run --verbose' - ps: >- if($env:APPVEYOR_SCHEDULED_BUILD -eq 'true') { diff --git a/.golangci.yml b/.golangci.yml index 3fb7dc86..6a4ea62b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,5 +1,5 @@ run: - deadline: 1m0s + timeout: 1m0s issues-exit-code: 1 tests: true skip-dirs: @@ -11,41 +11,46 @@ linters: disable-all: true enable: # defaults - - govet -# - errcheck - - staticcheck -# - unused - - gosimple - - structcheck -# - varcheck - - ineffassign # - deadcode +# - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - structcheck - typecheck +# - unused +# - varcheck # disabled by default linters # - bodyclose - - golint - - stylecheck - - gosec -# - interfacer - - unconvert + - depguard + - dogsled # - dupl +# - funlen +# - gochecknoglobals +# - gochecknoinits +# - gocognit - goconst + - gocritic # - gocyclo +# - godox - gofmt - goimports -# - maligned - - depguard - - misspell + - golint + - gosec +# - interfacer # - lll - - unparam +# - maligned + - misspell - nakedret # - prealloc - scopelint - - gocritic -# - gochecknoinits -# - gochecknoglobals -# - funlen + - stylecheck + - unconvert + - unparam + - whitespace +# - wsl linters-settings: govet: @@ -76,7 +81,4 @@ issues: exclude-rules: - text: "weak cryptographic primitive" linters: - - gosec - -service: - golangci-lint-version: 1.16.x \ No newline at end of file + - gosec \ No newline at end of file diff --git a/Makefile b/Makefile index df283681..6a5c7eff 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.18.0 +LINTPKG = github.com/golangci/golangci-lint/cmd/golangci-lint@v1.20.1 LINTBIN = $(GOPATH)/bin/golangci-lint GCTLISTENPORT=9050 GCTPROFILERLISTENPORT=8085 diff --git a/common/common_test.go b/common/common_test.go index 8905bb6f..ae049892 100644 --- a/common/common_test.go +++ b/common/common_test.go @@ -111,7 +111,6 @@ func TestGetMD5(t *testing.T) { t.Errorf("Test failed. Expected '%s'. Actual '%s'", expectedOutput, []byte(actualStr)) } - } func TestGetSHA512(t *testing.T) { @@ -197,7 +196,6 @@ func TestGetHMAC(t *testing.T) { expectedmd5, md5, ) } - } func TestSha1Tohex(t *testing.T) { @@ -838,7 +836,6 @@ func TestGetOSPathSlash(t *testing.T) { if output != "/" && output != "\\" { t.Errorf("Test failed. Common GetOSPathSlash. Returned '%s'", output) } - } func TestUnixMillis(t *testing.T) { diff --git a/communications/slack/slack.go b/communications/slack/slack.go index e91f7bd2..fabc361d 100644 --- a/communications/slack/slack.go +++ b/communications/slack/slack.go @@ -209,34 +209,28 @@ func (s *Slack) WebsocketReader() { } switch data.Type { - case "error": err = s.handleErrorResponse(data) if err != nil { continue } - case "hello": s.handleHelloResponse() - case "reconnect_url": err = s.handleReconnectResponse(resp) if err != nil { continue } - case "presence_change": err = s.handlePresenceChange(resp) if err != nil { continue } - case "message": err = s.handleMessageResponse(resp, data) if err != nil { continue } - case "pong": if s.Verbose { log.Debugf("Pong received from server") diff --git a/communications/slack/slack_test.go b/communications/slack/slack_test.go index db4f1263..9f3fad35 100644 --- a/communications/slack/slack_test.go +++ b/communications/slack/slack_test.go @@ -140,7 +140,6 @@ func TestGetUsernameByID(t *testing.T) { if username != "cranktakular" { t.Error("test failed - slack GetUsernameByID() error") } - } func TestGetIDByName(t *testing.T) { @@ -175,7 +174,6 @@ func TestGetGroupIDByName(t *testing.T) { t.Errorf("test failed - slack GetGroupIDByName() Expected '11223344' Actual '%s' Error: %s", id, err) } - } func TestGetChannelIDByName(t *testing.T) { diff --git a/config/config.go b/config/config.go index 5082f2c9..525ab026 100644 --- a/config/config.go +++ b/config/config.go @@ -338,7 +338,6 @@ func (c *Config) GetClientBankAccounts(exchangeName, targetCurrency string) (Ban c.BankAccounts[x].SupportedExchanges == "ALL") && common.StringContains(c.BankAccounts[x].SupportedCurrencies, targetCurrency) { return c.BankAccounts[x], nil - } } return BankAccount{}, fmt.Errorf("client banking details not found for %s and currency %s", @@ -496,7 +495,6 @@ func (c *Config) CheckCommunicationsConfig() { }, } } - } else { if c.SMS != nil { // flush old SMS config diff --git a/currency/code.go b/currency/code.go index b5f9154b..eb3913a1 100644 --- a/currency/code.go +++ b/currency/code.go @@ -803,9 +803,9 @@ var ( STQ = NewCode("STQ") INK = NewCode("INK") HBZ = NewCode("HBZ") - USDT_ETH = NewCode("USDT_ETH") // nolint: golint - QTUM_ETH = NewCode("QTUM_ETH") // nolint: golint - BTM_ETH = NewCode("BTM_ETH") // nolint: golint + USDT_ETH = NewCode("USDT_ETH") // nolint: stylecheck, golint + QTUM_ETH = NewCode("QTUM_ETH") // nolint: stylecheck + BTM_ETH = NewCode("BTM_ETH") // nolint: stylecheck, golint FIL = NewCode("FIL") STX = NewCode("STX") BOT = NewCode("BOT") @@ -818,7 +818,7 @@ var ( GOD = NewCode("GOD") SMT = NewCode("SMT") BTF = NewCode("BTF") - NAS_ETH = NewCode("NAS_ETH") // nolint: golint + NAS_ETH = NewCode("NAS_ETH") // nolint: stylecheck, golint TSL = NewCode("TSL") BIFI = NewCode("BIFI") BNTY = NewCode("BNTY") @@ -844,21 +844,21 @@ var ( MOBI = NewCode("MOBI") LEDU = NewCode("LEDU") DBC = NewCode("DBC") - MKR_OLD = NewCode("MKR_OLD") // nolint: golint + MKR_OLD = NewCode("MKR_OLD") // nolint: stylecheck, golint DPY = NewCode("DPY") BCDN = NewCode("BCDN") - EOSDAC = NewCode("EOSDAC") // nolint: golint + EOSDAC = NewCode("EOSDAC") // nolint: stylecheck TIPS = NewCode("TIPS") XMC = NewCode("XMC") PPS = NewCode("PPS") BOE = NewCode("BOE") MEDX = NewCode("MEDX") - SMT_ETH = NewCode("SMT_ETH") // nolint: golint + SMT_ETH = NewCode("SMT_ETH") // nolint: stylecheck, golint CS = NewCode("CS") MAN = NewCode("MAN") REM = NewCode("REM") LYM = NewCode("LYM") - INSTAR = NewCode("INSTAR") // nolint: golint + INSTAR = NewCode("INSTAR") // nolint: stylecheck BFT = NewCode("BFT") IHT = NewCode("IHT") SENC = NewCode("SENC") @@ -873,7 +873,7 @@ var ( SWTH = NewCode("SWTH") NKN = NewCode("NKN") SOUL = NewCode("SOUL") - GALA_NEO = NewCode("GALA_NEO") // nolint: golint + GALA_NEO = NewCode("GALA_NEO") // nolint: stylecheck, golint LRN = NewCode("LRN") GSE = NewCode("GSE") RATING = NewCode("RATING") @@ -2098,5 +2098,5 @@ var ( YER = NewCode("YER") ZWD = NewCode("ZWD") XETH = NewCode("XETH") - FX_BTC = NewCode("FX_BTC") // nolint: golint + FX_BTC = NewCode("FX_BTC") // nolint: stylecheck, golint ) diff --git a/currency/storage.go b/currency/storage.go index cebc28dc..4beaaf3f 100644 --- a/currency/storage.go +++ b/currency/storage.go @@ -377,7 +377,6 @@ func (s *Storage) WriteCurrencyDataToFile(path string, mainUpdate bool) error { // LoadFileCurrencyData loads currencies into the currency codes func (s *Storage) LoadFileCurrencyData(f *File) error { - for i := range f.Contracts { err := s.currencyCodes.LoadItem(&f.Contracts[i]) if err != nil { diff --git a/currency/symbol_test.go b/currency/symbol_test.go index 2fe3ae6a..5dd6447a 100644 --- a/currency/symbol_test.go +++ b/currency/symbol_test.go @@ -17,5 +17,4 @@ func TestGetSymbolByCurrencyName(t *testing.T) { if err == nil { t.Errorf("Test failed. TestGetSymbolByCurrencyNam returned nil on non-existent currency") } - } diff --git a/exchange.go b/exchange.go index 053e572f..7e9b0185 100644 --- a/exchange.go +++ b/exchange.go @@ -239,7 +239,6 @@ func SetupExchanges() { continue } return - } if !exch.Enabled { log.Debugf("%s: Exchange support: Disabled", exch.Name) diff --git a/exchanges/anx/anx.go b/exchanges/anx/anx.go index 684d6b9e..9b04cb60 100644 --- a/exchanges/anx/anx.go +++ b/exchanges/anx/anx.go @@ -204,7 +204,6 @@ func (a *ANX) GetDataToken() (string, error) { // NewOrder sends a new order request to the exchange. func (a *ANX) NewOrder(orderType string, buy bool, tradedCurrency string, tradedCurrencyAmount float64, settlementCurrency string, settlementCurrencyAmount, limitPriceSettlement float64, replace bool, replaceUUID string, replaceIfActive bool) (string, error) { - req := make(map[string]interface{}) var order Order order.OrderType = orderType diff --git a/exchanges/binance/binance_test.go b/exchanges/binance/binance_test.go index 674fc67a..f914f35f 100644 --- a/exchanges/binance/binance_test.go +++ b/exchanges/binance/binance_test.go @@ -243,7 +243,6 @@ func TestGetFee(t *testing.T) { t.Errorf("Test Failed - GetFee() error. Expected: %f, Received: %f", float64(0), resp) t.Error(err) } - } // CryptocurrencyWithdrawalFee Basic diff --git a/exchanges/bitfinex/bitfinex_test.go b/exchanges/bitfinex/bitfinex_test.go index 292c79b5..a4e7652e 100644 --- a/exchanges/bitfinex/bitfinex_test.go +++ b/exchanges/bitfinex/bitfinex_test.go @@ -222,7 +222,6 @@ func TestGetSymbols(t *testing.T) { "rrtusd", } if len(expectedCurrencies) <= len(symbols) { - for _, explicitSymbol := range expectedCurrencies { if common.StringDataCompare(expectedCurrencies, explicitSymbol) { break diff --git a/exchanges/bitfinex/bitfinex_websocket.go b/exchanges/bitfinex/bitfinex_websocket.go index e1138267..5e1aca49 100644 --- a/exchanges/bitfinex/bitfinex_websocket.go +++ b/exchanges/bitfinex/bitfinex_websocket.go @@ -201,7 +201,6 @@ func (b *Bitfinex) WsDataHandler() { if status == "OK" { b.Websocket.DataHandler <- eventData b.WsAddSubscriptionChannel(0, "account", "N/A") - } else if status == "fail" { b.Websocket.DataHandler <- fmt.Errorf("bitfinex.go error - Websocket unable to AUTH. Error code: %s", eventData["code"].(string)) diff --git a/exchanges/bitmex/bitmex_websocket.go b/exchanges/bitmex/bitmex_websocket.go index b4f7c07d..86f75d35 100644 --- a/exchanges/bitmex/bitmex_websocket.go +++ b/exchanges/bitmex/bitmex_websocket.go @@ -183,7 +183,6 @@ func (b *Bitmex) wsHandleIncomingData() { b.Websocket.DataHandler <- fmt.Errorf("%s websocket error: Unable to subscribe %s", b.Name, decodedResp.Subscribe) - } else if _, ok := quickCapture["table"]; ok { var decodedResp WebsocketMainResponse err := common.JSONDecode(resp.Raw, &decodedResp) diff --git a/exchanges/bitmex/bitmex_wrapper.go b/exchanges/bitmex/bitmex_wrapper.go index f40598e9..4a4ae9b0 100644 --- a/exchanges/bitmex/bitmex_wrapper.go +++ b/exchanges/bitmex/bitmex_wrapper.go @@ -36,7 +36,6 @@ func (b *Bitmex) Run() { marketInfo, err := b.GetActiveInstruments(&GenericRequestParams{}) if err != nil { log.Errorf("%s Failed to get available symbols.\n", b.GetName()) - } else { var exchangeProducts []string for i := range marketInfo { diff --git a/exchanges/bitstamp/bitstamp_wrapper.go b/exchanges/bitstamp/bitstamp_wrapper.go index 802f8682..68522421 100644 --- a/exchanges/bitstamp/bitstamp_wrapper.go +++ b/exchanges/bitstamp/bitstamp_wrapper.go @@ -66,7 +66,6 @@ func (b *Bitstamp) UpdateTicker(p currency.Pair, assetType string) (ticker.Price tick, err := b.GetTicker(p.String(), false) if err != nil { return tickerPrice, err - } tickerPrice.Pair = p tickerPrice.Ask = tick.Ask @@ -100,7 +99,6 @@ func (b *Bitstamp) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error feeBuilder.FeeType = exchange.OfflineTradeFee } return b.GetFee(feeBuilder) - } // GetOrderbookEx returns the orderbook for a currency pair diff --git a/exchanges/bittrex/bittrex.go b/exchanges/bittrex/bittrex.go index b9b0a18b..10345f9c 100644 --- a/exchanges/bittrex/bittrex.go +++ b/exchanges/bittrex/bittrex.go @@ -575,5 +575,4 @@ func (b *Bittrex) GetWithdrawalFee(c currency.Code) (float64, error) { // calculateTradingFee returns the fee for trading any currency on Bittrex func calculateTradingFee(price, amount float64) float64 { return 0.0025 * price * amount - } diff --git a/exchanges/bittrex/bittrex_wrapper.go b/exchanges/bittrex/bittrex_wrapper.go index adb24291..a692ae1f 100644 --- a/exchanges/bittrex/bittrex_wrapper.go +++ b/exchanges/bittrex/bittrex_wrapper.go @@ -306,7 +306,6 @@ func (b *Bittrex) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error) feeBuilder.FeeType = exchange.OfflineTradeFee } return b.GetFee(feeBuilder) - } // GetActiveOrders retrieves any orders that are active/open diff --git a/exchanges/btse/btse.go b/exchanges/btse/btse.go index e1ee9a93..adc862ed 100644 --- a/exchanges/btse/btse.go +++ b/exchanges/btse/btse.go @@ -166,7 +166,6 @@ func (b *BTSE) GetTrades(symbol string) ([]Trade, error) { var t []Trade endpoint := fmt.Sprintf("%s/%s", btseTrades, symbol) return t, b.SendHTTPRequest(http.MethodGet, endpoint, &t) - } // GetTicker returns the ticker for a specified symbol diff --git a/exchanges/btse/btse_test.go b/exchanges/btse/btse_test.go index 93439bfa..8e243faa 100644 --- a/exchanges/btse/btse_test.go +++ b/exchanges/btse/btse_test.go @@ -120,7 +120,6 @@ func TestGetFills(t *testing.T) { if err != nil { t.Error(err) } - } func TestCreateOrder(t *testing.T) { diff --git a/exchanges/btse/btse_wrapper.go b/exchanges/btse/btse_wrapper.go index 6dccba73..2e3ff51e 100644 --- a/exchanges/btse/btse_wrapper.go +++ b/exchanges/btse/btse_wrapper.go @@ -66,7 +66,6 @@ func (b *BTSE) UpdateTicker(p currency.Pair, assetType string) (ticker.Price, er s, err := b.GetMarketStatistics(exchange.FormatExchangeCurrency(b.Name, p).String()) if err != nil { return tickerPrice, err - } tickerPrice.Pair = p diff --git a/exchanges/coinbasepro/coinbasepro_test.go b/exchanges/coinbasepro/coinbasepro_test.go index 2e9ff69c..6f8f1c97 100644 --- a/exchanges/coinbasepro/coinbasepro_test.go +++ b/exchanges/coinbasepro/coinbasepro_test.go @@ -361,7 +361,6 @@ func TestCalculateTradingFee(t *testing.T) { } func TestFormatWithdrawPermissions(t *testing.T) { - c.SetDefaults() expectedResult := exchange.AutoWithdrawCryptoWithAPIPermissionText + " & " + exchange.AutoWithdrawFiatWithAPIPermissionText @@ -440,7 +439,6 @@ func TestSubmitOrder(t *testing.T) { } func TestCancelExchangeOrder(t *testing.T) { - c.SetDefaults() TestSetup(t) @@ -467,7 +465,6 @@ func TestCancelExchangeOrder(t *testing.T) { } func TestCancelAllExchangeOrders(t *testing.T) { - c.SetDefaults() TestSetup(t) diff --git a/exchanges/coinbasepro/coinbasepro_types.go b/exchanges/coinbasepro/coinbasepro_types.go index 23b75ea2..77afd7a0 100644 --- a/exchanges/coinbasepro/coinbasepro_types.go +++ b/exchanges/coinbasepro/coinbasepro_types.go @@ -447,7 +447,7 @@ type WebsocketTicker struct { BestBid float64 `json:"best_bid,string"` BestAsk float64 `json:"best_ask,string"` Side string `json:"side"` - Time time.Time `json:"time,string"` + Time time.Time `json:"time"` TradeID int64 `json:"trade_id"` LastSize float64 `json:"last_size,string"` } diff --git a/exchanges/coinut/coinut_test.go b/exchanges/coinut/coinut_test.go index 358c10d7..7d1d8506 100644 --- a/exchanges/coinut/coinut_test.go +++ b/exchanges/coinut/coinut_test.go @@ -234,7 +234,6 @@ func TestGetFee(t *testing.T) { } func TestFormatWithdrawPermissions(t *testing.T) { - c.SetDefaults() expectedResult := exchange.WithdrawCryptoViaWebsiteOnlyText + " & " + exchange.WithdrawFiatViaWebsiteOnlyText @@ -306,7 +305,6 @@ func TestSubmitOrder(t *testing.T) { } func TestCancelExchangeOrder(t *testing.T) { - c.SetDefaults() TestSetup(t) @@ -333,7 +331,6 @@ func TestCancelExchangeOrder(t *testing.T) { } func TestCancelAllExchangeOrders(t *testing.T) { - c.SetDefaults() TestSetup(t) diff --git a/exchanges/coinut/coinut_websocket.go b/exchanges/coinut/coinut_websocket.go index 262927b3..a0a840be 100644 --- a/exchanges/coinut/coinut_websocket.go +++ b/exchanges/coinut/coinut_websocket.go @@ -102,7 +102,6 @@ func (c *COINUT) WsHandleData() { } c.wsProcessResponse(individualJSON) } - } else { var incoming wsResponse err = common.JSONDecode(resp.Raw, &incoming) @@ -113,7 +112,6 @@ func (c *COINUT) WsHandleData() { c.wsProcessResponse(resp.Raw) } - } } } diff --git a/exchanges/coinut/coinut_wrapper.go b/exchanges/coinut/coinut_wrapper.go index 1ceed266..2bc9bba5 100644 --- a/exchanges/coinut/coinut_wrapper.go +++ b/exchanges/coinut/coinut_wrapper.go @@ -154,7 +154,6 @@ func (c *COINUT) UpdateTicker(p currency.Pair, assetType string) (ticker.Price, } return ticker.GetTicker(c.Name, p, assetType) - } // GetTickerPrice returns the ticker for a currency pair @@ -313,12 +312,10 @@ func (c *COINUT) CancelAllOrders(_ *exchange.OrderCancellation) (exchange.Cancel var allTheOrders []OrderResponse for _, allInstrumentData := range instruments.Instruments { for _, instrumentData := range allInstrumentData { - openOrders, err := c.GetOpenOrders(instrumentData.InstID) if err != nil { return cancelAllOrdersResponse, err } - allTheOrders = append(allTheOrders, openOrders.Orders...) } } diff --git a/exchanges/exmo/exmo_test.go b/exchanges/exmo/exmo_test.go index 4ae2daae..02af8411 100644 --- a/exchanges/exmo/exmo_test.go +++ b/exchanges/exmo/exmo_test.go @@ -250,7 +250,6 @@ func TestGetFee(t *testing.T) { } func TestFormatWithdrawPermissions(t *testing.T) { - e.SetDefaults() expectedResult := exchange.AutoWithdrawCryptoWithSetupText + " & " + exchange.NoFiatWithdrawalsText @@ -327,7 +326,6 @@ func TestSubmitOrder(t *testing.T) { } func TestCancelExchangeOrder(t *testing.T) { - e.SetDefaults() TestSetup(t) if areTestAPIKeysSet() && !canManipulateRealOrders { @@ -353,7 +351,6 @@ func TestCancelExchangeOrder(t *testing.T) { } func TestCancelAllExchangeOrders(t *testing.T) { - e.SetDefaults() TestSetup(t) diff --git a/exchanges/gemini/gemini.go b/exchanges/gemini/gemini.go index b4ed2fa1..516d71a2 100644 --- a/exchanges/gemini/gemini.go +++ b/exchanges/gemini/gemini.go @@ -175,7 +175,6 @@ func (g *Gemini) GetSymbols() ([]string, error) { // GetTicker returns information about recent trading activity for the symbol func (g *Gemini) GetTicker(currencyPair string) (Ticker, error) { - type TickerResponse struct { Ask float64 `json:"ask,string"` Bid float64 `json:"bid,string"` diff --git a/exchanges/hitbtc/hitbtc_types.go b/exchanges/hitbtc/hitbtc_types.go index 251c46e5..5adc456b 100644 --- a/exchanges/hitbtc/hitbtc_types.go +++ b/exchanges/hitbtc/hitbtc_types.go @@ -22,12 +22,12 @@ type Ticker struct { // TickerResponse is the response type type TickerResponse struct { - Last string `json:"last"` // Last trade price - Ask string `json:"ask"` // Best ask price - Bid string `json:"bid"` // Best bid price - Timestamp time.Time `json:"timestamp,string"` // Last update or refresh ticker timestamp - Volume string `json:"volume"` // Total trading amount within 24 hours in base currency - VolumeQuote string `json:"volumeQuote"` // Total trading amount within 24 hours in quote currency + Last string `json:"last"` // Last trade price + Ask string `json:"ask"` // Best ask price + Bid string `json:"bid"` // Best bid price + Timestamp time.Time `json:"timestamp"` // Last update or refresh ticker timestamp + Volume string `json:"volume"` // Total trading amount within 24 hours in base currency + VolumeQuote string `json:"volumeQuote"` // Total trading amount within 24 hours in quote currency Symbol string `json:"symbol"` High string `json:"high"` // Highest trade price within 24 hours Low string `json:"low"` // Lowest trade price within 24 hours @@ -75,7 +75,7 @@ type TradeHistory struct { // ChartData contains chart data type ChartData struct { - Timestamp time.Time `json:"timestamp,string"` + Timestamp time.Time `json:"timestamp"` Max float64 `json:"max,string"` // Max price Min float64 `json:"min,string"` // Min price Open float64 `json:"open,string"` // Open price @@ -88,7 +88,7 @@ type ChartData struct { type Currencies struct { ID string `json:"id"` // Currency identifier. FullName string `json:"fullName"` // Currency full name - Crypto bool `json:"crypto,boolean"` // Is currency belongs to blockchain (false for ICO and fiat, like EUR) + Crypto bool `json:"crypto"` // Is currency belongs to blockchain (false for ICO and fiat, like EUR) PayinEnabled bool `json:"payinEnabled"` // Is allowed for deposit (false for ICO) PayinPaymentID bool `json:"payinPaymentId"` // Is required to provide additional information other than the address for deposit PayinConfirmations int64 `json:"payinConfirmations"` // Blocks confirmations count for deposit @@ -148,10 +148,10 @@ type Order struct { Quantity float64 `json:"quantity,string"` // Order quantity Price float64 `json:"price,string"` // Order price CumQuantity float64 `json:"cumQuantity,string"` // Cumulative executed quantity - CreatedAt time.Time `json:"createdAt,string"` - UpdatedAt time.Time `json:"updatedAt,string"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` StopPrice float64 `json:"stopPrice,string"` - ExpireTime time.Time `json:"expireTime,string"` + ExpireTime time.Time `json:"expireTime"` } // OpenOrdersResponseAll holds the full open order response @@ -274,7 +274,7 @@ type LoanOffer struct { Rate float64 `json:"rate,string"` Amount float64 `json:"amount,string"` Duration int `json:"duration"` - AutoRenew bool `json:"autoRenew,int"` + AutoRenew bool `json:"autoRenew"` Date string `json:"date"` } diff --git a/exchanges/kraken/kraken.go b/exchanges/kraken/kraken.go index 9a7737c7..91d365dd 100644 --- a/exchanges/kraken/kraken.go +++ b/exchanges/kraken/kraken.go @@ -567,7 +567,6 @@ func (k *Kraken) GetTradeBalance(args ...TradeBalanceOptions) (TradeBalanceInfo, if len(args[0].Asset) > 0 { params.Set("asset", args[0].Asset) } - } var response struct { diff --git a/exchanges/lakebtc/lakebtc_wrapper.go b/exchanges/lakebtc/lakebtc_wrapper.go index d898a32a..b0e735b3 100644 --- a/exchanges/lakebtc/lakebtc_wrapper.go +++ b/exchanges/lakebtc/lakebtc_wrapper.go @@ -215,7 +215,6 @@ func (l *LakeBTC) CancelAllOrders(_ *exchange.OrderCancellation) (exchange.Cance } return cancelAllOrdersResponse, l.CancelExistingOrders(ordersToCancel) - } // GetOrderInfo returns information on a current open order diff --git a/exchanges/lbank/lbank.go b/exchanges/lbank/lbank.go index 07f95f81..599bfaa7 100644 --- a/exchanges/lbank/lbank.go +++ b/exchanges/lbank/lbank.go @@ -230,7 +230,6 @@ func (l *Lbank) GetKlines(symbol, size, klineType, time string) ([]KlineResponse } else { tempResp.TradingVolume = resp2[x].(float64) } - } } k = append(k, tempResp) diff --git a/exchanges/lbank/lbank_wrapper.go b/exchanges/lbank/lbank_wrapper.go index dfeeefeb..a525c46c 100644 --- a/exchanges/lbank/lbank_wrapper.go +++ b/exchanges/lbank/lbank_wrapper.go @@ -510,7 +510,6 @@ func (l *Lbank) getAllOpenOrderID() (map[string][]string, error) { for c := 0; c < tempData; c++ { resp[exchange.FormatExchangeCurrency(l.Name, p).String()] = append(resp[exchange.FormatExchangeCurrency(l.Name, p).String()], tempResp.Orders[c].OrderID) - } tempData = len(tempResp.Orders) b++ diff --git a/exchanges/localbitcoins/localbitcoins_types.go b/exchanges/localbitcoins/localbitcoins_types.go index d0b3e337..6d145505 100644 --- a/exchanges/localbitcoins/localbitcoins_types.go +++ b/exchanges/localbitcoins/localbitcoins_types.go @@ -106,7 +106,7 @@ type AdEdit struct { MaxAmount int `json:"max_amount"` OpeningHours []string `json:"opening_hours"` LimitToFiatAmounts string `json:"limit_to_fiat_amounts"` - Visible bool `json:"visible,int"` + Visible bool `json:"visible"` // Optional Arguments ONLINE_SELL ads RequireTradeVolume int `json:"require_trade_volume"` @@ -114,13 +114,13 @@ type AdEdit struct { FirstTimeLimitBTC int `json:"first_time_limit_btc"` VolumeCoefficientBTC int `json:"volume_coefficient_btc"` ReferenceType string `json:"reference_type"` - DisplayReference bool `json:"display_reference,int"` + DisplayReference bool `json:"display_reference"` // Optional Arguments ONLINE_BUY PaymentWindowMinutes int `json:"payment_window_minutes"` // Optional Arguments LOCAL_SELL - Floating bool `json:"floating,int"` + Floating bool `json:"floating"` } // AdCreate references an outgoing paramater type for CreateAd() method @@ -148,7 +148,7 @@ type AdCreate struct { MaxAmount int `json:"max_amount"` OpeningHours []string `json:"opening_hours"` LimitToFiatAmounts string `json:"limit_to_fiat_amounts"` - Visible bool `json:"visible,int"` + Visible bool `json:"visible"` // Optional Arguments ONLINE_SELL ads RequireTradeVolume int `json:"require_trade_volume"` @@ -156,13 +156,13 @@ type AdCreate struct { FirstTimeLimitBTC int `json:"first_time_limit_btc"` VolumeCoefficientBTC int `json:"volume_coefficient_btc"` ReferenceType string `json:"reference_type"` - DisplayReference bool `json:"display_reference,int"` + DisplayReference bool `json:"display_reference"` // Optional Arguments ONLINE_BUY PaymentWindowMinutes int `json:"payment_window_minutes"` // Optional Arguments LOCAL_SELL - Floating bool `json:"floating,int"` + Floating bool `json:"floating"` } // Message holds the returned message data from a contact diff --git a/exchanges/localbitcoins/localbitcoins_wrapper.go b/exchanges/localbitcoins/localbitcoins_wrapper.go index 6e5286b4..6e8ccb6b 100644 --- a/exchanges/localbitcoins/localbitcoins_wrapper.go +++ b/exchanges/localbitcoins/localbitcoins_wrapper.go @@ -55,7 +55,6 @@ func (l *LocalBitcoins) Run() { if err != nil { log.Errorf("%s failed to update available currencies. Err %s", l.Name, err) } - } // UpdateTicker updates and returns the ticker for a currency pair diff --git a/exchanges/mock/recording.go b/exchanges/mock/recording.go index c15f4d58..5cbaa6ab 100644 --- a/exchanges/mock/recording.go +++ b/exchanges/mock/recording.go @@ -419,7 +419,6 @@ func GetExcludedItems() (Exclusion, error) { if mErr != nil { return excludedList, mErr } - } else { err = json.Unmarshal(file, &excludedList) if err != nil { diff --git a/exchanges/okcoin/okcoin_test.go b/exchanges/okcoin/okcoin_test.go index b22a6d2e..558fc1f0 100644 --- a/exchanges/okcoin/okcoin_test.go +++ b/exchanges/okcoin/okcoin_test.go @@ -1077,7 +1077,6 @@ func TestCancelExchangeOrder(t *testing.T) { err := o.CancelOrder(&orderCancellation) testStandardErrorHandling(t, err) - } // TestCancelAllExchangeOrders Wrapper test diff --git a/exchanges/okex/okex.go b/exchanges/okex/okex.go index 7382459a..45418360 100644 --- a/exchanges/okex/okex.go +++ b/exchanges/okex/okex.go @@ -88,7 +88,6 @@ func (o *OKEX) SetDefaults() { o.WebsocketResponseMaxLimit = exchange.DefaultWebsocketResponseMaxLimit o.WebsocketResponseCheckTimeout = exchange.DefaultWebsocketResponseCheckTimeout o.WebsocketOrderbookBufferLimit = exchange.DefaultWebsocketOrderbookBufferLimit - } // GetFuturesPostions Get the information of all holding positions in futures trading. diff --git a/exchanges/okex/okex_test.go b/exchanges/okex/okex_test.go index 481d8fb8..b1d5aff5 100644 --- a/exchanges/okex/okex_test.go +++ b/exchanges/okex/okex_test.go @@ -1846,7 +1846,6 @@ func TestCancelExchangeOrder(t *testing.T) { err := o.CancelOrder(&orderCancellation) testStandardErrorHandling(t, err) - } // TestCancelAllExchangeOrders Wrapper test diff --git a/exchanges/okgroup/okgroup.go b/exchanges/okgroup/okgroup.go index cf127dd5..5d2aeb27 100644 --- a/exchanges/okgroup/okgroup.go +++ b/exchanges/okgroup/okgroup.go @@ -668,7 +668,6 @@ func (o *OKGroup) SendHTTPRequest(httpMethod, requestType, requestPath string, d if !errCap.Result { return errors.New("unspecified error occurred") } - } return common.JSONDecode(intermediary, result) diff --git a/exchanges/okgroup/okgroup_websocket.go b/exchanges/okgroup/okgroup_websocket.go index bbabfc47..41b44ee3 100644 --- a/exchanges/okgroup/okgroup_websocket.go +++ b/exchanges/okgroup/okgroup_websocket.go @@ -313,7 +313,6 @@ func (o *OKGroup) GetAssetTypeFromTableName(table string) string { // WsHandleDataResponse classifies the WS response and sends to appropriate handler func (o *OKGroup) WsHandleDataResponse(response *WebsocketDataResponse) { switch o.GetWsChannelWithoutOrderType(response.Table) { - case okGroupWsCandle60s, okGroupWsCandle180s, okGroupWsCandle300s, okGroupWsCandle900s, okGroupWsCandle1800s, okGroupWsCandle3600s, okGroupWsCandle7200s, okGroupWsCandle14400s, okGroupWsCandle21600s, okGroupWsCandle43200s, okGroupWsCandle86400s, okGroupWsCandle604900s: @@ -502,7 +501,6 @@ func (o *OKGroup) WsProcessUpdateOrderbook(wsEventData *WebsocketDataWrapper, in Asset: o.GetAssetTypeFromTableName(tableName), Pair: instrument, } - } else { if o.Verbose { log.Debug("Orderbook invalid") @@ -527,7 +525,6 @@ func (o *OKGroup) CalculatePartialOrderbookChecksum(orderbookData *WebsocketData } if len(orderbookData.Asks)-1 >= i { askMessage = fmt.Sprintf("%v:%v:", orderbookData.Asks[i][0], orderbookData.Asks[i][1]) - } if checksum == "" { checksum = fmt.Sprintf("%v%v", bidsMessage, askMessage) diff --git a/exchanges/poloniex/poloniex_types.go b/exchanges/poloniex/poloniex_types.go index f21b61e8..d664f880 100644 --- a/exchanges/poloniex/poloniex_types.go +++ b/exchanges/poloniex/poloniex_types.go @@ -261,7 +261,7 @@ type LoanOffer struct { Rate float64 `json:"rate,string"` Amount float64 `json:"amount,string"` Duration int `json:"duration"` - AutoRenew bool `json:"autoRenew,int"` + AutoRenew bool `json:"autoRenew"` Date string `json:"date"` } diff --git a/exchanges/ticker/ticker_test.go b/exchanges/ticker/ticker_test.go index 77f5e626..0781bcb2 100644 --- a/exchanges/ticker/ticker_test.go +++ b/exchanges/ticker/ticker_test.go @@ -389,5 +389,4 @@ func TestProcessTicker(t *testing.T) { // non-appending function to tickers } } wg.Wait() - } diff --git a/exchanges/websocket/wshandler/wshandler.go b/exchanges/websocket/wshandler/wshandler.go index debfd55d..d0a9166a 100644 --- a/exchanges/websocket/wshandler/wshandler.go +++ b/exchanges/websocket/wshandler/wshandler.go @@ -40,7 +40,6 @@ func (w *Websocket) Setup(connector func() error, defaultURL, runningURL string, authenticatedWebsocketAPISupport bool) error { - w.DataHandler = make(chan interface{}, 1) w.Connected = make(chan struct{}, 1) w.Disconnected = make(chan struct{}, 1) diff --git a/exchanges/websocket/wsorderbook/wsorderbook_test.go b/exchanges/websocket/wsorderbook/wsorderbook_test.go index 6aba611a..2f5516f5 100644 --- a/exchanges/websocket/wsorderbook/wsorderbook_test.go +++ b/exchanges/websocket/wsorderbook/wsorderbook_test.go @@ -434,7 +434,6 @@ func TestFlushCache(t *testing.T) { if obl.ob[curr][spot] != nil { t.Error("expected ob be flushed") } - } // TestInsertingSnapShots logic test diff --git a/exchanges/zb/zb_websocket_types.go b/exchanges/zb/zb_websocket_types.go index ea95b9bf..4faef0a0 100644 --- a/exchanges/zb/zb_websocket_types.go +++ b/exchanges/zb/zb_websocket_types.go @@ -77,7 +77,7 @@ type WsAddSubUserRequest struct { Memo string `json:"memo"` Password string `json:"password"` SubUserName string `json:"subUserName"` - No int64 `json:"no,string,omtempty"` + No int64 `json:"no,string,omitempty"` Sign string `json:"sign,omitempty"` } diff --git a/helpers.go b/helpers.go index f8781dd2..3e0f490a 100644 --- a/helpers.go +++ b/helpers.go @@ -345,7 +345,6 @@ func SeedExchangeAccountInfo(data []exchange.AccountInfo) { var currencies []exchange.AccountCurrencyInfo for _, account := range exchangeData.Accounts { for _, info := range account.Currencies { - var update bool for i := range currencies { if info.CurrencyName == currencies[i].CurrencyName { @@ -388,7 +387,6 @@ func SeedExchangeAccountInfo(data []exchange.AccountInfo) { CoinType: currencyName, Balance: total, Description: portfolio.PortfolioAddressExchange}) - } else { if total <= 0 { log.Debugf("Portfolio: Removing %s %s entry.\n", diff --git a/main.go b/main.go index d8f43fc3..725b5730 100644 --- a/main.go +++ b/main.go @@ -157,7 +157,6 @@ func main() { *verbosity) if err != nil { log.Fatalf("currency updater system failed to start %v", err) - } bot.portfolio = &portfolio.Portfolio diff --git a/portfolio/portfolio.go b/portfolio/portfolio.go index e5f2f217..e645e6b3 100644 --- a/portfolio/portfolio.go +++ b/portfolio/portfolio.go @@ -347,7 +347,6 @@ func (p *Base) GetPortfolioSummary() Summary { Percentage: getPercentageSpecific(z, y, totalCoins), } coinSummary[y] = coinSum - } exchangeSummary[exchgName] = coinSummary } diff --git a/portfolio/portfolio_test.go b/portfolio/portfolio_test.go index af3ed905..2bc79317 100644 --- a/portfolio/portfolio_test.go +++ b/portfolio/portfolio_test.go @@ -108,7 +108,6 @@ func TestExchangeAddressExists(t *testing.T) { if newbase.ExchangeAddressExists("TEST", currency.LTC) { t.Error("Test Failed - portfolio_test.go - ExchangeAddressExists error") } - } func TestAddExchangeAddress(t *testing.T) { diff --git a/restful_router.go b/restful_router.go index 3d46059a..08ee7f65 100644 --- a/restful_router.go +++ b/restful_router.go @@ -10,7 +10,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" log "github.com/thrasher-corp/gocryptotrader/logger" - _ "net/http/pprof" + _ "net/http/pprof" // nolint: gosec ) // RESTLogger logs the requests internally diff --git a/restful_server.go b/restful_server.go index a3184306..3b7d3466 100644 --- a/restful_server.go +++ b/restful_server.go @@ -159,7 +159,6 @@ func GetAllActiveOrderbooks() []EnabledExchangeOrderbooks { ) } orderbookData = append(orderbookData, individualExchange) - } return orderbookData } diff --git a/tools/huobi_auth/main.go b/tools/huobi_auth/main.go index 5e10b495..319c99d2 100644 --- a/tools/huobi_auth/main.go +++ b/tools/huobi_auth/main.go @@ -96,7 +96,6 @@ func main() { if err != nil { log.Fatal(err) } - } else { var pubKeyData []byte pubKeyData, err = common.ReadFile("publickey.pem")