Migrate from gometalinter.v2 to golangci-lint (#249)

* Migrate from gometalinter.v2 to golangci-lint
This commit is contained in:
Adrian Gallagher
2019-03-01 16:10:29 +11:00
committed by GitHub
parent 81852f2e01
commit 7dcb1ab553
133 changed files with 2179 additions and 2204 deletions

View File

@@ -648,7 +648,7 @@ func (b *Binance) CheckLimit(limit int) error {
return nil
}
}
return errors.New("Incorrect limit values - valid values are 5, 10, 20, 50, 100, 500, 1000")
return errors.New("incorrect limit values - valid values are 5, 10, 20, 50, 100, 500, 1000")
}
// CheckSymbol checks value against a variable list
@@ -659,7 +659,7 @@ func (b *Binance) CheckSymbol(symbol string) error {
return nil
}
}
return errors.New("Incorrect symbol values - please check available pairs in configuration")
return errors.New("incorrect symbol values - please check available pairs in configuration")
}
// CheckIntervals checks value against a variable list
@@ -669,7 +669,7 @@ func (b *Binance) CheckIntervals(interval string) error {
return nil
}
}
return errors.New(`Incorrect interval values - valid values are "1m","3m","5m","15m","30m","1h","2h","4h","6h","8h","12h","1d","3d","1w","1M"`)
return errors.New(`incorrect interval values - valid values are "1m","3m","5m","15m","30m","1h","2h","4h","6h","8h","12h","1d","3d","1w","1M"`)
}
// SetValues sets the default valid values
@@ -766,7 +766,7 @@ func (b *Binance) WithdrawCrypto(asset, address, addressTag, name, amount string
return resp.ID, nil
}
//GetDepositAddressForCurrency retrieves the wallet address for a given currency
// GetDepositAddressForCurrency retrieves the wallet address for a given currency
func (b *Binance) GetDepositAddressForCurrency(currency string) (string, error) {
path := fmt.Sprintf("%s%s", b.APIUrl, depositAddress)

View File

@@ -290,8 +290,8 @@ type NewOrderRequest struct {
Quantity float64
Price float64
NewClientOrderID string
StopPrice float64 //Used with STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders.
IcebergQty float64 //Used with LIMIT, STOP_LOSS_LIMIT, and TAKE_PROFIT_LIMIT to create an iceberg order.
StopPrice float64 // Used with STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders.
IcebergQty float64 // Used with LIMIT, STOP_LOSS_LIMIT, and TAKE_PROFIT_LIMIT to create an iceberg order.
NewOrderRespType string
}

View File

@@ -109,7 +109,7 @@ func (b *Binance) UpdateLocalCache(ob WebsocketDepthStream) error {
priceToBeUpdated.Amount, _ = strconv.ParseFloat(asks.(string), 64)
}
}
updateAsk = append(updateBid, priceToBeUpdated)
updateAsk = append(updateAsk, priceToBeUpdated)
}
updatedTime := time.Unix(ob.Timestamp, 0)
@@ -132,7 +132,7 @@ func (b *Binance) WSConnect() error {
var Dialer websocket.Dialer
var err error
ticker := strings.ToLower(
tick := strings.ToLower(
strings.Replace(
strings.Join(b.EnabledPairs, "@ticker/"), "-", "", -1)) + "@ticker"
trade := strings.ToLower(
@@ -147,7 +147,7 @@ func (b *Binance) WSConnect() error {
wsurl := b.Websocket.GetWebsocketURL() +
"/stream?streams=" +
ticker +
tick +
"/" +
trade +
"/" +
@@ -220,8 +220,7 @@ func (b *Binance) WsHandleData() {
return
}
switch read.Type {
case websocket.TextMessage:
if read.Type == websocket.TextMessage {
multiStreamData := MultiStreamData{}
err = common.JSONDecode(read.Raw, &multiStreamData)
if err != nil {
@@ -230,7 +229,8 @@ func (b *Binance) WsHandleData() {
continue
}
if strings.Contains(multiStreamData.Stream, "trade") {
switch multiStreamData.Stream {
case "trade":
trade := TradeStream{}
err := common.JSONDecode(multiStreamData.Data, &trade)
@@ -264,8 +264,7 @@ func (b *Binance) WsHandleData() {
Side: trade.EventType,
}
continue
} else if strings.Contains(multiStreamData.Stream, "ticker") {
case "ticker":
t := TickerStream{}
err := common.JSONDecode(multiStreamData.Data, &t)
@@ -289,8 +288,7 @@ func (b *Binance) WsHandleData() {
b.Websocket.DataHandler <- wsTicker
continue
} else if strings.Contains(multiStreamData.Stream, "kline") {
case "kline":
kline := KlineStream{}
err := common.JSONDecode(multiStreamData.Data, &kline)
@@ -317,8 +315,7 @@ func (b *Binance) WsHandleData() {
b.Websocket.DataHandler <- wsKline
continue
} else if common.StringContains(multiStreamData.Stream, "depth") {
case "depth":
depth := WebsocketDepthStream{}
err := common.JSONDecode(multiStreamData.Data, &depth)

View File

@@ -76,16 +76,17 @@ func (b *Binance) UpdateTicker(p pair.CurrencyPair, assetType string) (ticker.Pr
for _, x := range b.GetEnabledCurrencies() {
curr := exchange.FormatExchangeCurrency(b.Name, x)
for y := range tick {
if tick[y].Symbol == curr.String() {
tickerPrice.Pair = x
tickerPrice.Ask = tick[y].AskPrice
tickerPrice.Bid = tick[y].BidPrice
tickerPrice.High = tick[y].HighPrice
tickerPrice.Last = tick[y].LastPrice
tickerPrice.Low = tick[y].LowPrice
tickerPrice.Volume = tick[y].Volume
ticker.ProcessTicker(b.Name, x, tickerPrice, assetType)
if tick[y].Symbol != curr.String() {
continue
}
tickerPrice.Pair = x
tickerPrice.Ask = tick[y].AskPrice
tickerPrice.Bid = tick[y].BidPrice
tickerPrice.High = tick[y].HighPrice
tickerPrice.Last = tick[y].LastPrice
tickerPrice.Low = tick[y].LowPrice
tickerPrice.Volume = tick[y].Volume
ticker.ProcessTicker(b.Name, x, tickerPrice, assetType)
}
}
return ticker.GetTicker(b.Name, p, assetType)
@@ -192,13 +193,14 @@ func (b *Binance) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orde
}
var requestParamsOrderType RequestParamsOrderType
if orderType == exchange.MarketOrderType {
switch orderType {
case exchange.MarketOrderType:
requestParamsOrderType = BinanceRequestParamsOrderMarket
} else if orderType == exchange.LimitOrderType {
case exchange.LimitOrderType:
requestParamsOrderType = BinanceRequestParamsOrderLimit
} else {
default:
submitOrderResponse.IsOrderPlaced = false
return submitOrderResponse, errors.New("Unsupported order type")
return submitOrderResponse, errors.New("unsupported order type")
}
var orderRequest = NewOrderRequest{
@@ -306,8 +308,8 @@ func (b *Binance) GetFeeByType(feeBuilder exchange.FeeBuilder) (float64, error)
// GetActiveOrders retrieves any orders that are active/open
func (b *Binance) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {
if len(getOrdersRequest.Currencies) <= 0 {
return nil, errors.New("At least one currency is required to fetch order history")
if len(getOrdersRequest.Currencies) == 0 {
return nil, errors.New("at least one currency is required to fetch order history")
}
var orders []exchange.OrderDetail
@@ -346,8 +348,8 @@ func (b *Binance) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([
// GetOrderHistory retrieves account order information
// Can Limit response to specific order status
func (b *Binance) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {
if len(getOrdersRequest.Currencies) <= 0 {
return nil, errors.New("At least one currency is required to fetch order history")
if len(getOrdersRequest.Currencies) == 0 {
return nil, errors.New("at least one currency is required to fetch order history")
}
var orders []exchange.OrderDetail