Linter fixes (#246)

Linter fixes
This commit is contained in:
Adrian Gallagher
2019-02-05 16:26:04 +11:00
committed by GitHub
parent d7368c1a8d
commit 5e5ca8a887
85 changed files with 641 additions and 794 deletions

View File

@@ -4,6 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"net/http"
"strconv"
"strings"
"time"
@@ -189,13 +190,8 @@ func (g *Gateio) GetLatestSpotPrice(symbol string) (float64, error) {
// updated every 10 seconds
func (g *Gateio) GetTicker(symbol string) (TickerResponse, error) {
url := fmt.Sprintf("%s/%s/%s/%s", g.APIUrlSecondary, gateioAPIVersion, gateioTicker, symbol)
var res TickerResponse
err := g.SendHTTPRequest(url, &res)
if err != nil {
return res, err
}
return res, nil
return res, g.SendHTTPRequest(url, &res)
}
// GetTickers returns tickers for all symbols
@@ -347,7 +343,7 @@ func (g *Gateio) GetBalances() (BalancesResponse, error) {
var result BalancesResponse
return result,
g.SendAuthenticatedHTTPRequest("POST", gateioBalances, "", &result)
g.SendAuthenticatedHTTPRequest(http.MethodPost, gateioBalances, "", &result)
}
// SpotNewOrder places a new order
@@ -362,13 +358,7 @@ func (g *Gateio) SpotNewOrder(arg SpotNewOrderRequestParams) (SpotNewOrderRespon
)
strRequestURL := fmt.Sprintf("%s/%s", gateioOrder, arg.Type)
err := g.SendAuthenticatedHTTPRequest("POST", strRequestURL, params, &result)
if err != nil {
return result, err
}
return result, nil
return result, g.SendAuthenticatedHTTPRequest(http.MethodPost, strRequestURL, params, &result)
}
// CancelExistingOrder cancels an order given the supplied orderID and symbol
@@ -387,7 +377,7 @@ func (g *Gateio) CancelExistingOrder(orderID int64, symbol string) (bool, error)
orderID,
symbol,
)
err := g.SendAuthenticatedHTTPRequest("POST", gateioCancelOrder, params, &result)
err := g.SendAuthenticatedHTTPRequest(http.MethodPost, gateioCancelOrder, params, &result)
if err != nil {
return false, err
}
@@ -400,7 +390,7 @@ func (g *Gateio) CancelExistingOrder(orderID int64, symbol string) (bool, error)
// SendHTTPRequest sends an unauthenticated HTTP request
func (g *Gateio) SendHTTPRequest(path string, result interface{}) error {
return g.SendPayload("GET", path, nil, nil, result, false, g.Verbose)
return g.SendPayload(http.MethodGet, path, nil, nil, result, false, g.Verbose)
}
// CancelAllExistingOrders all orders for a given symbol and side
@@ -417,7 +407,7 @@ func (g *Gateio) CancelAllExistingOrders(orderType int64, symbol string) error {
orderType,
symbol,
)
err := g.SendAuthenticatedHTTPRequest("POST", gateioCancelAllOrders, params, &result)
err := g.SendAuthenticatedHTTPRequest(http.MethodPost, gateioCancelAllOrders, params, &result)
if err != nil {
return err
}
@@ -438,7 +428,7 @@ func (g *Gateio) GetOpenOrders(symbol string) (OpenOrdersResponse, error) {
params = fmt.Sprintf("currencyPair=%s", symbol)
}
err := g.SendAuthenticatedHTTPRequest("POST", gateioOpenOrders, params, &result)
err := g.SendAuthenticatedHTTPRequest(http.MethodPost, gateioOpenOrders, params, &result)
if err != nil {
return result, err
}
@@ -456,7 +446,7 @@ func (g *Gateio) GetTradeHistory(symbol string) (TradHistoryResponse, error) {
var result TradHistoryResponse
params = fmt.Sprintf("currencyPair=%s", symbol)
err := g.SendAuthenticatedHTTPRequest("POST", gateioTradeHistory, params, &result)
err := g.SendAuthenticatedHTTPRequest(http.MethodPost, gateioTradeHistory, params, &result)
if err != nil {
return result, err
}
@@ -560,7 +550,7 @@ func (g *Gateio) WithdrawCrypto(currency, address string, amount float64) (strin
address,
amount,
)
err := g.SendAuthenticatedHTTPRequest("POST", gateioWithdraw, params, &result)
err := g.SendAuthenticatedHTTPRequest(http.MethodPost, gateioWithdraw, params, &result)
if err != nil {
return "", err
}
@@ -568,7 +558,7 @@ func (g *Gateio) WithdrawCrypto(currency, address string, amount float64) (strin
return "", fmt.Errorf("code:%d message:%s", result.Code, result.Message)
}
return "", nil
return result.Message, nil
}
// GetCryptoDepositAddress returns a deposit address for a cryptocurrency
@@ -584,7 +574,7 @@ func (g *Gateio) GetCryptoDepositAddress(currency string) (string, error) {
params := fmt.Sprintf("currency=%s",
currency)
err := g.SendAuthenticatedHTTPRequest("POST", gateioDepositAddress, params, &result)
err := g.SendAuthenticatedHTTPRequest(http.MethodPost, gateioDepositAddress, params, &result)
if err != nil {
return "", err
}

View File

@@ -188,7 +188,8 @@ func (g *Gateio) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]ex
}
// SubmitOrder submits a new order
func (g *Gateio) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error) {
// TODO: support multiple order types (IOC)
func (g *Gateio) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, _ exchange.OrderType, amount, price float64, _ string) (exchange.SubmitOrderResponse, error) {
var submitOrderResponse exchange.SubmitOrderResponse
var orderTypeFormat SpotNewOrderRequestParamsType
@@ -237,7 +238,7 @@ func (g *Gateio) CancelOrder(order exchange.OrderCancellation) error {
}
// CancelAllOrders cancels all orders associated with a currency pair
func (g *Gateio) CancelAllOrders(orderCancellation exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
func (g *Gateio) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
cancelAllOrdersResponse := exchange.CancelAllOrdersResponse{
OrderStatus: make(map[string]string),
}
@@ -268,7 +269,7 @@ func (g *Gateio) GetOrderInfo(orderID int64) (exchange.OrderDetail, error) {
}
// GetDepositAddress returns a deposit address for a specified currency
func (g *Gateio) GetDepositAddress(cryptocurrency pair.CurrencyItem, accountID string) (string, error) {
func (g *Gateio) GetDepositAddress(cryptocurrency pair.CurrencyItem, _ string) (string, error) {
addr, err := g.GetCryptoDepositAddress(cryptocurrency.String())
if err != nil {
return "", err