Bump golangci-lint to v1.24.0, linter fixes and general code improvements (#478)

* Bump golangci-lint version, update Go version deps and generic code improvements

* Fix wesbocket resp nil check and zip closures

* Update pprof path
This commit is contained in:
Adrian Gallagher
2020-04-09 13:07:32 +10:00
committed by GitHub
parent 4748a7849c
commit 0d787bc259
47 changed files with 193 additions and 178 deletions

View File

@@ -14,7 +14,7 @@ import (
)
var (
dbConn *database.Db
dbConn *database.Instance
)
type databaseManager struct {

View File

@@ -24,8 +24,9 @@ var (
// should not be exported as it can have large impact if used improperly
func (o *orderStore) get() map[string][]*order.Detail {
o.m.RLock()
defer o.m.RUnlock()
return o.Orders
orders := o.Orders
o.m.RUnlock()
return orders
}
// GetByExchangeAndID returns a specific order by exchange and id

View File

@@ -3,7 +3,7 @@ package engine
import (
"fmt"
"net/http"
_ "net/http/pprof" // nolint: gosec
"net/http/pprof"
"runtime"
"strconv"
"strings"
@@ -90,10 +90,10 @@ func newRouter(isREST bool) *mux.Router {
runtime.SetMutexProfileFraction(Bot.Config.Profiler.MutexProfileFraction)
}
log.Debugf(log.RESTSys,
"HTTP Go performance profiler (pprof) endpoint enabled: http://%s:%d/debug/pprof\n",
"HTTP Go performance profiler (pprof) endpoint enabled: http://%s:%d/debug/pprof/\n",
common.ExtractHost(listenAddr),
common.ExtractPort(listenAddr))
router.PathPrefix("/debug").Handler(http.DefaultServeMux)
router.PathPrefix("/debug/pprof/").HandlerFunc(pprof.Index)
}
} else {
routes = []Route{

View File

@@ -412,7 +412,6 @@ func (e *ExchangeCurrencyPairSyncer) worker() {
}
printTickerSummary(result, c.Pair, c.AssetType, exchangeName, "REST", err)
if err == nil {
//nolint:gocritic Bot.CommsRelayer.StageTickerData(exchangeName, c.AssetType, result)
if Bot.Config.RemoteControl.WebsocketRPC.Enabled {
relayWebsocketEvent(result, "ticker_update", c.AssetType.String(), exchangeName)
}
@@ -452,7 +451,6 @@ func (e *ExchangeCurrencyPairSyncer) worker() {
result, err := exchanges[x].UpdateOrderbook(c.Pair, c.AssetType)
printOrderbookSummary(result, c.Pair, c.AssetType, exchangeName, "REST", err)
if err == nil {
//nolint:gocritic Bot.CommsRelayer.StageOrderbookData(exchangeName, c.AssetType, result)
if Bot.Config.RemoteControl.WebsocketRPC.Enabled {
relayWebsocketEvent(result, "orderbook_update", c.AssetType.String(), exchangeName)
}

View File

@@ -151,7 +151,7 @@ func (c *WebsocketClient) write() {
defer func() {
c.Conn.Close()
}()
for { // nolint: gosimple
for { // nolint // ws client write routine loop
select {
case message, ok := <-c.Send:
if !ok {