Replace a zero-length, non-nil slice with a nil slice (#299)

* Replace a zero-length, non-nil slice with a nil slice

* Update codelingo.yaml
This commit is contained in:
leilaes
2019-05-16 12:19:08 +12:00
committed by Adrian Gallagher
parent 07216a4422
commit cdab89a58a
26 changed files with 90 additions and 99 deletions

View File

@@ -6,7 +6,7 @@ tenets:
- import: codelingo/effective-go/single-method-interface-name
- import: codelingo/effective-go/underscores-in-name
- import: codelingo/effective-go/unnecessary-else
- import: codelingo/code-review-comments/declare-empty-slice
# Overwrite one tenet with custom logic
# - import: codelingo/effective-go/comment-first-word-when-empty
- name: comment-first-word-when-empty

View File

@@ -715,7 +715,7 @@ func TestExtractPort(t *testing.T) {
func TestOutputCSV(t *testing.T) {
path := "../testdata/dump"
data := [][]string{}
var data [][]string
rowOne := []string{"Appended", "to", "two", "dimensional", "array"}
rowTwo := []string{"Appended", "to", "two", "dimensional", "array", "two"}
data = append(data, rowOne, rowTwo)

View File

@@ -239,7 +239,7 @@ func (b *Binance) GetOrderBook(obd OrderBookDataRequestParams) (OrderBook, error
// GetRecentTrades returns recent trade activity
// limit: Up to 500 results returned
func (b *Binance) GetRecentTrades(rtr RecentTradeRequestParams) ([]RecentTrade, error) {
resp := []RecentTrade{}
var resp []RecentTrade
params := url.Values{}
params.Set("symbol", common.StringToUpper(rtr.Symbol))
@@ -256,7 +256,7 @@ func (b *Binance) GetRecentTrades(rtr RecentTradeRequestParams) ([]RecentTrade,
// limit: Optional. Default 500; max 1000.
// fromID:
func (b *Binance) GetHistoricalTrades(symbol string, limit int, fromID int64) ([]HistoricalTrade, error) {
resp := []HistoricalTrade{}
var resp []HistoricalTrade
if err := b.CheckLimit(limit); err != nil {
return resp, err
@@ -277,7 +277,7 @@ func (b *Binance) GetHistoricalTrades(symbol string, limit int, fromID int64) ([
// symbol: string of currency pair
// limit: Optional. Default 500; max 1000.
func (b *Binance) GetAggregatedTrades(symbol string, limit int) ([]AggregatedTrade, error) {
resp := []AggregatedTrade{}
var resp []AggregatedTrade
if err := b.CheckLimit(limit); err != nil {
return resp, err

View File

@@ -310,7 +310,7 @@ func (b *Bitfinex) GetTickersV2(symbols string) ([]Tickersv2, error) {
// GetStats returns various statistics about the requested pair
func (b *Bitfinex) GetStats(symbol string) ([]Stat, error) {
response := []Stat{}
var response []Stat
path := fmt.Sprint(b.APIUrl + bitfinexAPIVersion + bitfinexStats + symbol)
return response, b.SendHTTPRequest(path, &response, b.Verbose)
@@ -402,7 +402,7 @@ func (b *Bitfinex) GetOrderbookV2(symbol, precision string, values url.Values) (
// Values can contain limit amounts for the number of trades returned - Example
// "limit_trades" = 1000
func (b *Bitfinex) GetTrades(currencyPair string, values url.Values) ([]TradeStructure, error) {
response := []TradeStructure{}
var response []TradeStructure
path := common.EncodeURLValues(
b.APIUrl+bitfinexAPIVersion+bitfinexTrades+currencyPair,
values,
@@ -480,7 +480,7 @@ func (b *Bitfinex) GetLendbook(symbol string, values url.Values) (Lendbook, erro
// over time
// Symbol - example "USD"
func (b *Bitfinex) GetLends(symbol string, values url.Values) ([]Lends, error) {
response := []Lends{}
var response []Lends
path := common.EncodeURLValues(b.APIUrl+bitfinexAPIVersion+bitfinexLends+symbol,
values)
@@ -489,7 +489,7 @@ func (b *Bitfinex) GetLends(symbol string, values url.Values) ([]Lends, error) {
// GetSymbols returns the available currency pairs on the exchange
func (b *Bitfinex) GetSymbols() ([]string, error) {
products := []string{}
var products []string
path := fmt.Sprint(b.APIUrl + bitfinexAPIVersion + bitfinexSymbols)
return products, b.SendHTTPRequest(path, &products, b.Verbose)
@@ -497,7 +497,7 @@ func (b *Bitfinex) GetSymbols() ([]string, error) {
// GetSymbolsDetails a list of valid symbol IDs and the pair details
func (b *Bitfinex) GetSymbolsDetails() ([]SymbolDetails, error) {
response := []SymbolDetails{}
var response []SymbolDetails
path := fmt.Sprint(b.APIUrl + bitfinexAPIVersion + bitfinexSymbolsDetails)
return response, b.SendHTTPRequest(path, &response, b.Verbose)
@@ -560,7 +560,7 @@ func (b *Bitfinex) GetKeyPermissions() (KeyPermissions, error) {
// GetMarginInfo shows your trading wallet information for margin trading
func (b *Bitfinex) GetMarginInfo() ([]MarginInfo, error) {
response := []MarginInfo{}
var response []MarginInfo
return response,
b.SendAuthenticatedHTTPRequest(http.MethodPost,
@@ -569,7 +569,7 @@ func (b *Bitfinex) GetMarginInfo() ([]MarginInfo, error) {
// GetAccountBalance returns full wallet balance information
func (b *Bitfinex) GetAccountBalance() ([]Balance, error) {
response := []Balance{}
var response []Balance
return response,
b.SendAuthenticatedHTTPRequest(http.MethodPost,
@@ -582,7 +582,7 @@ func (b *Bitfinex) GetAccountBalance() ([]Balance, error) {
// WalletFrom - example "exchange"
// WalletTo - example "deposit"
func (b *Bitfinex) WalletTransfer(amount float64, currency, walletFrom, walletTo string) ([]WalletTransfer, error) {
response := []WalletTransfer{}
var response []WalletTransfer
req := make(map[string]interface{})
req["amount"] = amount
req["currency"] = currency
@@ -599,7 +599,7 @@ func (b *Bitfinex) WalletTransfer(amount float64, currency, walletFrom, walletTo
// WithdrawCryptocurrency requests a withdrawal from one of your wallets.
// For FIAT, use WithdrawFIAT
func (b *Bitfinex) WithdrawCryptocurrency(withdrawType, wallet, address, paymentID string, amount float64, c currency.Code) ([]Withdrawal, error) {
response := []Withdrawal{}
var response []Withdrawal
req := make(map[string]interface{})
req["withdraw_type"] = withdrawType
req["walletselected"] = wallet
@@ -618,7 +618,7 @@ func (b *Bitfinex) WithdrawCryptocurrency(withdrawType, wallet, address, payment
// WithdrawFIAT requests a withdrawal from a designated fiat wallet
func (b *Bitfinex) WithdrawFIAT(withdrawalType, walletType string, withdrawRequest *exchange.WithdrawRequest) ([]Withdrawal, error) {
response := []Withdrawal{}
var response []Withdrawal
req := make(map[string]interface{})
req["withdraw_type"] = withdrawalType
@@ -787,7 +787,7 @@ func (b *Bitfinex) GetOpenOrders() ([]Order, error) {
// GetActivePositions returns an array of active positions
func (b *Bitfinex) GetActivePositions() ([]Position, error) {
response := []Position{}
var response []Position
return response,
b.SendAuthenticatedHTTPRequest(http.MethodPost,
@@ -811,7 +811,7 @@ func (b *Bitfinex) ClaimPosition(positionID int) (Position, error) {
// GetBalanceHistory returns balance history for the account
func (b *Bitfinex) GetBalanceHistory(symbol string, timeSince, timeUntil time.Time, limit int, wallet string) ([]BalanceHistory, error) {
response := []BalanceHistory{}
var response []BalanceHistory
req := make(map[string]interface{})
req["currency"] = symbol
@@ -837,7 +837,7 @@ func (b *Bitfinex) GetBalanceHistory(symbol string, timeSince, timeUntil time.Ti
// GetMovementHistory returns an array of past deposits and withdrawals
func (b *Bitfinex) GetMovementHistory(symbol, method string, timeSince, timeUntil time.Time, limit int) ([]MovementHistory, error) {
response := []MovementHistory{}
var response []MovementHistory
req := make(map[string]interface{})
req["currency"] = symbol
@@ -863,7 +863,7 @@ func (b *Bitfinex) GetMovementHistory(symbol, method string, timeSince, timeUnti
// GetTradeHistory returns past executed trades
func (b *Bitfinex) GetTradeHistory(currencyPair string, timestamp, until time.Time, limit, reverse int) ([]TradeHistory, error) {
response := []TradeHistory{}
var response []TradeHistory
req := make(map[string]interface{})
req["currency"] = currencyPair
req["timestamp"] = timestamp
@@ -931,7 +931,7 @@ func (b *Bitfinex) GetOfferStatus(offerID int64) (Offer, error) {
// GetActiveCredits returns all available credits
func (b *Bitfinex) GetActiveCredits() ([]Offer, error) {
response := []Offer{}
var response []Offer
return response,
b.SendAuthenticatedHTTPRequest(http.MethodPost,
@@ -942,7 +942,7 @@ func (b *Bitfinex) GetActiveCredits() ([]Offer, error) {
// GetActiveOffers returns all current active offers
func (b *Bitfinex) GetActiveOffers() ([]Offer, error) {
response := []Offer{}
var response []Offer
return response,
b.SendAuthenticatedHTTPRequest(http.MethodPost,
@@ -953,7 +953,7 @@ func (b *Bitfinex) GetActiveOffers() ([]Offer, error) {
// GetActiveMarginFunding returns an array of active margin funds
func (b *Bitfinex) GetActiveMarginFunding() ([]MarginFunds, error) {
response := []MarginFunds{}
var response []MarginFunds
return response,
b.SendAuthenticatedHTTPRequest(http.MethodPost,
@@ -965,7 +965,7 @@ func (b *Bitfinex) GetActiveMarginFunding() ([]MarginFunds, error) {
// GetUnusedMarginFunds returns an array of funding borrowed but not currently
// used
func (b *Bitfinex) GetUnusedMarginFunds() ([]MarginFunds, error) {
response := []MarginFunds{}
var response []MarginFunds
return response,
b.SendAuthenticatedHTTPRequest(http.MethodPost,
@@ -977,7 +977,7 @@ func (b *Bitfinex) GetUnusedMarginFunds() ([]MarginFunds, error) {
// GetMarginTotalTakenFunds returns an array of active funding used in a
// position
func (b *Bitfinex) GetMarginTotalTakenFunds() ([]MarginTotalTakenFunds, error) {
response := []MarginTotalTakenFunds{}
var response []MarginTotalTakenFunds
return response,
b.SendAuthenticatedHTTPRequest(http.MethodPost,

View File

@@ -286,7 +286,7 @@ func (b *Bitfinex) WsDataHandler() {
switch chanInfo.Channel {
case "book":
newOrderbook := []WebsocketBook{}
var newOrderbook []WebsocketBook
switch len(chanData) {
case 2:
data := chanData[1].([]interface{})
@@ -340,7 +340,7 @@ func (b *Bitfinex) WsDataHandler() {
case "account":
switch chanData[1].(string) {
case bitfinexWebsocketPositionSnapshot:
positionSnapshot := []WebsocketPosition{}
var positionSnapshot []WebsocketPosition
data := chanData[2].([]interface{})
for _, x := range data {
y := x.([]interface{})
@@ -374,7 +374,7 @@ func (b *Bitfinex) WsDataHandler() {
case bitfinexWebsocketWalletSnapshot:
data := chanData[2].([]interface{})
walletSnapshot := []WebsocketWallet{}
var walletSnapshot []WebsocketWallet
for _, x := range data {
y := x.([]interface{})
walletSnapshot = append(walletSnapshot,
@@ -398,7 +398,7 @@ func (b *Bitfinex) WsDataHandler() {
b.Websocket.DataHandler <- wallet
case bitfinexWebsocketOrderSnapshot:
orderSnapshot := []WebsocketOrder{}
var orderSnapshot []WebsocketOrder
data := chanData[2].([]interface{})
for _, x := range data {
y := x.([]interface{})
@@ -447,7 +447,7 @@ func (b *Bitfinex) WsDataHandler() {
}
case "trades":
trades := []WebsocketTrade{}
var trades []WebsocketTrade
switch len(chanData) {
case 2:
data := chanData[1].([]interface{})

View File

@@ -316,7 +316,7 @@ func (b *Bitstamp) GetTradingPairs() ([]TradingPair, error) {
// value paramater ["time"] = "minute", "hour", "day" will collate your
// response into time intervals. Implementation of value in test code.
func (b *Bitstamp) GetTransactions(currencyPair string, values url.Values) ([]Transactions, error) {
transactions := []Transactions{}
var transactions []Transactions
path := common.EncodeURLValues(
fmt.Sprintf(
"%s/v%s/%s/%s/",
@@ -361,7 +361,7 @@ func (b *Bitstamp) GetUserTransactions(currencyPair string) ([]UserTransactions,
Fee float64 `json:"fee,string"`
OrderID int64 `json:"order_id"`
}
response := []Response{}
var response []Response
if currencyPair != "" {
if err := b.SendAuthenticatedHTTPRequest(bitstampAPIUserTransactions, true, url.Values{}, &response); err != nil {
@@ -373,7 +373,7 @@ func (b *Bitstamp) GetUserTransactions(currencyPair string) ([]UserTransactions,
}
}
transactions := []UserTransactions{}
var transactions []UserTransactions
for _, y := range response {
tx := UserTransactions{}
@@ -416,7 +416,7 @@ func (b *Bitstamp) GetUserTransactions(currencyPair string) ([]UserTransactions,
// GetOpenOrders returns all open orders on the exchange
func (b *Bitstamp) GetOpenOrders(currencyPair string) ([]Order, error) {
resp := []Order{}
var resp []Order
path := fmt.Sprintf(
"%s/%s", bitstampAPIOpenOrders, common.StringToLower(currencyPair),
)
@@ -478,7 +478,7 @@ func (b *Bitstamp) PlaceOrder(currencyPair string, price, amount float64, buy, m
// timedelta - positive integer with max value 50000000 which returns requests
// from number of seconds ago to now.
func (b *Bitstamp) GetWithdrawalRequests(timedelta int64) ([]WithdrawalRequests, error) {
resp := []WithdrawalRequests{}
var resp []WithdrawalRequests
if timedelta > 50000000 || timedelta < 0 {
return resp, errors.New("time delta exceeded, max: 50000000 min: 0")
}
@@ -613,7 +613,7 @@ func (b *Bitstamp) GetCryptoDepositAddress(crypto currency.Code) (string, error)
// GetUnconfirmedBitcoinDeposits returns unconfirmed transactions
func (b *Bitstamp) GetUnconfirmedBitcoinDeposits() ([]UnconfirmedBTCTransactions, error) {
response := []UnconfirmedBTCTransactions{}
var response []UnconfirmedBTCTransactions
return response,
b.SendAuthenticatedHTTPRequest(bitstampAPIUnconfirmedBitcoin, false, nil, &response)

View File

@@ -165,7 +165,7 @@ func (b *BTCMarkets) GetOrderbook(firstPair, secondPair string) (Orderbook, erro
// symbol - example "btc" or "ltc"
// values - optional paramater "since" example values.Set(since, "59868345231")
func (b *BTCMarkets) GetTrades(firstPair, secondPair string, values url.Values) ([]Trade, error) {
trades := []Trade{}
var trades []Trade
path := common.EncodeURLValues(fmt.Sprintf("%s/market/%s/%s/trades",
b.APIUrl, common.StringToUpper(firstPair),
common.StringToUpper(secondPair)), values)
@@ -352,7 +352,7 @@ func (b *BTCMarkets) GetOrderDetail(orderID []int64) ([]Order, error) {
// GetAccountBalance returns the full account balance
func (b *BTCMarkets) GetAccountBalance() ([]AccountBalance, error) {
balance := []AccountBalance{}
var balance []AccountBalance
err := b.SendAuthenticatedRequest(http.MethodGet, btcMarketsAccountBalance, nil, &balance)
if err != nil {

View File

@@ -144,7 +144,7 @@ func (c *CoinbasePro) Setup(exch *config.ExchangeConfig) {
// GetProducts returns supported currency pairs on the exchange with specific
// information about the pair
func (c *CoinbasePro) GetProducts() ([]Product, error) {
products := []Product{}
var products []Product
return products, c.SendHTTPRequest(c.APIUrl+coinbaseproProducts, &products)
}
@@ -233,7 +233,7 @@ func (c *CoinbasePro) GetTicker(currencyPair string) (Ticker, error) {
// GetTrades listd the latest trades for a product
// currencyPair - example "BTC-USD"
func (c *CoinbasePro) GetTrades(currencyPair string) ([]Trade, error) {
trades := []Trade{}
var trades []Trade
path := fmt.Sprintf(
"%s/%s/%s", c.APIUrl+coinbaseproProducts, currencyPair, coinbaseproTrades)
@@ -244,7 +244,7 @@ func (c *CoinbasePro) GetTrades(currencyPair string) ([]Trade, error) {
// grouped buckets based on requested granularity.
func (c *CoinbasePro) GetHistoricRates(currencyPair string, start, end, granularity int64) ([]History, error) {
var resp [][]interface{}
history := []History{}
var history []History
values := url.Values{}
if start > 0 {
@@ -300,7 +300,7 @@ func (c *CoinbasePro) GetStats(currencyPair string) (Stats, error) {
// GetCurrencies returns a list of supported currency on the exchange
// Warning: Not all currencies may be currently in use for tradinc.
func (c *CoinbasePro) GetCurrencies() ([]Currency, error) {
currencies := []Currency{}
var currencies []Currency
return currencies, c.SendHTTPRequest(c.APIUrl+coinbaseproCurrencies, &currencies)
}
@@ -314,7 +314,7 @@ func (c *CoinbasePro) GetServerTime() (ServerTime, error) {
// GetAccounts returns a list of trading accounts associated with the APIKEYS
func (c *CoinbasePro) GetAccounts() ([]AccountResponse, error) {
resp := []AccountResponse{}
var resp []AccountResponse
return resp,
c.SendAuthenticatedHTTPRequest(http.MethodGet, coinbaseproAccounts, nil, &resp)
@@ -333,7 +333,7 @@ func (c *CoinbasePro) GetAccount(accountID string) (AccountResponse, error) {
// increases or decreases your account balance. Items are paginated and sorted
// latest first.
func (c *CoinbasePro) GetAccountHistory(accountID string) ([]AccountLedgerResponse, error) {
resp := []AccountLedgerResponse{}
var resp []AccountLedgerResponse
path := fmt.Sprintf("%s/%s/%s", coinbaseproAccounts, accountID, coinbaseproLedger)
return resp, c.SendAuthenticatedHTTPRequest(http.MethodGet, path, nil, &resp)
@@ -344,7 +344,7 @@ func (c *CoinbasePro) GetAccountHistory(accountID string) ([]AccountLedgerRespon
// is updated. If an order is canceled, any remaining hold is removed. For a
// withdraw, once it is completed, the hold is removed.
func (c *CoinbasePro) GetHolds(accountID string) ([]AccountHolds, error) {
resp := []AccountHolds{}
var resp []AccountHolds
path := fmt.Sprintf("%s/%s/%s", coinbaseproAccounts, accountID, coinbaseproHolds)
return resp, c.SendAuthenticatedHTTPRequest(http.MethodGet, path, nil, &resp)
@@ -514,7 +514,7 @@ func (c *CoinbasePro) CancelAllExistingOrders(currencyPair string) ([]string, er
// status - can be a range of "open", "pending", "done" or "active"
// currencyPair - [optional] for example "BTC-USD"
func (c *CoinbasePro) GetOrders(status []string, currencyPair string) ([]GeneralizedOrderResponse, error) {
resp := []GeneralizedOrderResponse{}
var resp []GeneralizedOrderResponse
params := url.Values{}
for _, individualStatus := range status {
@@ -541,7 +541,7 @@ func (c *CoinbasePro) GetOrder(orderID string) (GeneralizedOrderResponse, error)
// GetFills returns a list of recent fills
func (c *CoinbasePro) GetFills(orderID, currencyPair string) ([]FillResponse, error) {
resp := []FillResponse{}
var resp []FillResponse
params := url.Values{}
if orderID != "" {
@@ -566,7 +566,7 @@ func (c *CoinbasePro) GetFills(orderID, currencyPair string) ([]FillResponse, er
//
// status - "outstanding", "settled", or "rejected"
func (c *CoinbasePro) GetFundingRecords(status string) ([]Funding, error) {
resp := []Funding{}
var resp []Funding
params := url.Values{}
params.Set("status", status)
@@ -636,7 +636,7 @@ func (c *CoinbasePro) ClosePosition(repayOnly bool) (AccountOverview, error) {
// GetPayMethods returns a full list of payment methods
func (c *CoinbasePro) GetPayMethods() ([]PaymentMethod, error) {
resp := []PaymentMethod{}
var resp []PaymentMethod
return resp,
c.SendAuthenticatedHTTPRequest(http.MethodGet, coinbaseproPaymentMethod, nil, &resp)
@@ -729,7 +729,7 @@ func (c *CoinbasePro) WithdrawCrypto(amount float64, currency, cryptoAddress str
// GetCoinbaseAccounts returns a list of coinbase accounts
func (c *CoinbasePro) GetCoinbaseAccounts() ([]CoinbaseAccounts, error) {
resp := []CoinbaseAccounts{}
var resp []CoinbaseAccounts
return resp,
c.SendAuthenticatedHTTPRequest(http.MethodGet, coinbaseproCoinbaseAccounts, nil, &resp)
@@ -784,7 +784,7 @@ func (c *CoinbasePro) GetReportStatus(reportID string) (Report, error) {
// GetTrailingVolume this request will return your 30-day trailing volume for
// all products.
func (c *CoinbasePro) GetTrailingVolume() ([]Volume, error) {
resp := []Volume{}
var resp []Volume
return resp,
c.SendAuthenticatedHTTPRequest(http.MethodGet, coinbaseproTrailingVolume, nil, &resp)

View File

@@ -22,7 +22,7 @@ const (
// WebsocketSubscriber subscribes to websocket channels with respect to enabled
// currencies
func (c *CoinbasePro) WebsocketSubscriber() error {
currencies := []string{}
var currencies []string
for _, x := range c.EnabledPairs.Strings() {
currency := x[0:3] + "-" + x[3:]
currencies = append(currencies, currency)

View File

@@ -36,7 +36,7 @@ func (c *CoinbasePro) Run() {
if err != nil {
log.Errorf("%s Failed to get available products.\n", c.GetName())
} else {
currencies := []string{}
var currencies []string
for _, x := range exchangeProducts {
if x.ID != "BTC" && x.ID != "USD" && x.ID != "GBP" {
currencies = append(currencies, x.ID[0:3]+x.ID[4:])

View File

@@ -252,7 +252,7 @@ func (c *COINUT) CancelOrders(orders []CancelOrders) (CancelOrdersResponse, erro
OrderID int `json:"order_id"`
}
entries := []CancelOrders{}
var entries []CancelOrders
entries = append(entries, orders...)
params["entries"] = entries

View File

@@ -39,7 +39,7 @@ func (c *COINUT) Run() {
return
}
currencies := []string{}
var currencies []string
c.InstrumentMap = make(map[string]int)
for x, y := range exchangeProducts.Instruments {
c.InstrumentMap[x] = y[0].InstID

View File

@@ -896,7 +896,7 @@ func (e *Base) SupportsWithdrawPermissions(permissions uint32) bool {
// FormatWithdrawPermissions will return each of the exchange's compatible withdrawal methods in readable form
func (e *Base) FormatWithdrawPermissions() string {
services := []string{}
var services []string
for i := 0; i < 32; i++ {
var check uint32 = 1 << uint32(i)
if e.GetWithdrawPermissions()&check != 0 {

View File

@@ -645,7 +645,7 @@ func (w *Websocket) SupportsFunctionality(f uint32) bool {
// FormatFunctionality will return each of the websocket connection compatible
// stream methods as a string
func (w *Websocket) FormatFunctionality() string {
functionality := []string{}
var functionality []string
for i := 0; i < 32; i++ {
var check uint32 = 1 << uint32(i)
if w.GetFunctionality()&check != 0 {

View File

@@ -154,7 +154,7 @@ func (e *EXMO) GetPairSettings() (map[string]PairSettings, error) {
// GetCurrency returns a list of currencies
func (e *EXMO) GetCurrency() ([]string, error) {
result := []string{}
var result []string
urlPath := fmt.Sprintf("%s/v%s/%s", e.APIUrl, exmoAPIVersion, exmoCurrency)
return result, e.SendHTTPRequest(urlPath, &result)
}

View File

@@ -292,7 +292,7 @@ func (g *Gateio) GetSpotKline(arg KlinesRequestParams) ([]*KLineResponse, error)
}
rawKlineDatasString, _ := json.Marshal(rawKlines["data"].([]interface{}))
rawKlineDatas := [][]interface{}{}
var rawKlineDatas [][]interface{}
if err := json.Unmarshal(rawKlineDatasString, &rawKlineDatas); err != nil {
return nil, fmt.Errorf("rawKlines unmarshal failed. Err: %s", err)
}

View File

@@ -178,7 +178,7 @@ func (g *Gemini) Setup(exch *config.ExchangeConfig) {
// GetSymbols returns all available symbols for trading
func (g *Gemini) GetSymbols() ([]string, error) {
symbols := []string{}
var symbols []string
path := fmt.Sprintf("%s/v%s/%s", g.APIUrl, geminiAPIVersion, geminiSymbols)
return symbols, g.SendHTTPRequest(path, &symbols)
@@ -255,7 +255,7 @@ func (g *Gemini) GetOrderbook(currencyPair string, params url.Values) (Orderbook
// default. Can be '1' or 'true' to activate
func (g *Gemini) GetTrades(currencyPair string, params url.Values) ([]Trade, error) {
path := common.EncodeURLValues(fmt.Sprintf("%s/v%s/%s/%s", g.APIUrl, geminiAPIVersion, geminiTrades, currencyPair), params)
trades := []Trade{}
var trades []Trade
return trades, g.SendHTTPRequest(path, &trades)
}
@@ -281,7 +281,7 @@ func (g *Gemini) GetAuction(currencyPair string) (Auction, error) {
// indicative prices and quantities.
func (g *Gemini) GetAuctionHistory(currencyPair string, params url.Values) ([]AuctionHistory, error) {
path := common.EncodeURLValues(fmt.Sprintf("%s/v%s/%s/%s/%s", g.APIUrl, geminiAPIVersion, geminiAuction, currencyPair, geminiAuctionHistory), params)
auctionHist := []AuctionHistory{}
var auctionHist []AuctionHistory
return auctionHist, g.SendHTTPRequest(path, &auctionHist)
}
@@ -397,7 +397,7 @@ func (g *Gemini) GetOrders() ([]Order, error) {
// currencyPair - example "btcusd"
// timestamp - [optional] Only return trades on or after this timestamp.
func (g *Gemini) GetTradeHistory(currencyPair string, timestamp int64) ([]TradeHistory, error) {
response := []TradeHistory{}
var response []TradeHistory
req := make(map[string]interface{})
req["symbol"] = currencyPair
@@ -419,7 +419,7 @@ func (g *Gemini) GetNotionalVolume() (NotionalVolume, error) {
// GetTradeVolume returns a multi-arrayed volume response
func (g *Gemini) GetTradeVolume() ([][]TradeVolume, error) {
response := [][]TradeVolume{}
var response [][]TradeVolume
return response,
g.SendAuthenticatedHTTPRequest(http.MethodPost, geminiTradeVolume, nil, &response)
@@ -427,7 +427,7 @@ func (g *Gemini) GetTradeVolume() ([][]TradeVolume, error) {
// GetBalances returns available balances in the supported currencies
func (g *Gemini) GetBalances() ([]Balance, error) {
response := []Balance{}
var response []Balance
return response,
g.SendAuthenticatedHTTPRequest(http.MethodPost, geminiBalances, nil, &response)

View File

@@ -172,7 +172,7 @@ func (h *HitBTC) GetCurrency(currency string) (Currencies, error) {
// pair indicates how much of the quote currency is needed to purchase one unit
// of the base currency.
func (h *HitBTC) GetSymbols(symbol string) ([]string, error) {
resp := []Symbol{}
var resp []Symbol
path := fmt.Sprintf("%s/%s/%s", h.APIUrl, apiV2Symbol, symbol)
ret := make([]string, 0, len(resp))
@@ -190,7 +190,7 @@ func (h *HitBTC) GetSymbols(symbol string) ([]string, error) {
// GetSymbolsDetailed is the same as above but returns an array of symbols with
// all their details.
func (h *HitBTC) GetSymbolsDetailed() ([]Symbol, error) {
resp := []Symbol{}
var resp []Symbol
path := fmt.Sprintf("%s/%s", h.APIUrl, apiV2Symbol)
return resp, h.SendHTTPRequest(path, &resp)
@@ -198,7 +198,7 @@ func (h *HitBTC) GetSymbolsDetailed() ([]Symbol, error) {
// GetTicker returns ticker information
func (h *HitBTC) GetTicker(symbol string) (map[string]Ticker, error) {
resp1 := []TickerResponse{}
var resp1 []TickerResponse
resp2 := TickerResponse{}
ret := make(map[string]TickerResponse)
result := make(map[string]Ticker)
@@ -292,7 +292,7 @@ func (h *HitBTC) GetTrades(currencyPair, from, till, limit, offset, by, sort str
vals.Set("sort", sort)
}
resp := []TradeHistory{}
var resp []TradeHistory
path := fmt.Sprintf("%s/%s/%s?%s", h.APIUrl, apiV2Trades, currencyPair, vals.Encode())
return resp, h.SendHTTPRequest(path, &resp)
@@ -337,7 +337,7 @@ func (h *HitBTC) GetCandles(currencyPair, limit, period string) ([]ChartData, er
vals.Set("period", period)
}
resp := []ChartData{}
var resp []ChartData
path := fmt.Sprintf("%s/%s/%s?%s", h.APIUrl, apiV2Candles, currencyPair, vals.Encode())
return resp, h.SendHTTPRequest(path, &resp)
@@ -348,7 +348,7 @@ func (h *HitBTC) GetCandles(currencyPair, limit, period string) ([]ChartData, er
// GetBalances returns full balance for your account
func (h *HitBTC) GetBalances() (map[string]Balance, error) {
result := []Balance{}
var result []Balance
err := h.SendAuthenticatedHTTPRequest(http.MethodGet, apiV2Balance, url.Values{}, &result)
ret := make(map[string]Balance)
@@ -384,7 +384,7 @@ func (h *HitBTC) GenerateNewAddress(currency string) (DepositCryptoAddresses, er
// GetActiveorders returns all your active orders
func (h *HitBTC) GetActiveorders(currency string) ([]Order, error) {
resp := []Order{}
var resp []Order
err := h.SendAuthenticatedHTTPRequest(http.MethodGet, orders+"?symbol="+currency, url.Values{}, &resp)
return resp, err

View File

@@ -142,7 +142,7 @@ func (i *ItBit) GetTradeHistory(currencyPair, timestamp string) (Trades, error)
// page - [optional] page to return example 1. default 1
// perPage - [optional] items per page example 50, default 50 max 50
func (i *ItBit) GetWallets(params url.Values) ([]Wallet, error) {
resp := []Wallet{}
var resp []Wallet
params.Set("userId", i.ClientID)
path := fmt.Sprintf("/%s?%s", itbitWallets, params.Encode())

View File

@@ -205,7 +205,7 @@ func (l *LakeBTC) GetOrderBook(currency string) (Orderbook, error) {
// GetTradeHistory returns the trade history for a given currency pair
func (l *LakeBTC) GetTradeHistory(currency string) ([]TradeHistory, error) {
path := fmt.Sprintf("%s/%s?symbol=%s", l.APIUrl, lakeBTCTrades, common.StringToLower(currency))
resp := []TradeHistory{}
var resp []TradeHistory
return resp, l.SendHTTPRequest(path, &resp)
}
@@ -242,7 +242,7 @@ func (l *LakeBTC) Trade(isBuyOrder bool, amount, price float64, currency string)
// GetOpenOrders returns all open orders associated with your account
func (l *LakeBTC) GetOpenOrders() ([]OpenOrders, error) {
orders := []OpenOrders{}
var orders []OpenOrders
return orders, l.SendAuthenticatedHTTPRequest(lakeBTCOpenOrders, "", &orders)
}
@@ -254,7 +254,7 @@ func (l *LakeBTC) GetOrders(orders []int64) ([]Orders, error) {
ordersStr = append(ordersStr, strconv.FormatInt(x, 10))
}
resp := []Orders{}
var resp []Orders
return resp,
l.SendAuthenticatedHTTPRequest(lakeBTCGetOrders, common.JoinStrings(ordersStr, ","), &resp)
}
@@ -304,13 +304,13 @@ func (l *LakeBTC) GetTrades(timestamp int64) ([]AuthenticatedTradeHistory, error
params = strconv.FormatInt(timestamp, 10)
}
trades := []AuthenticatedTradeHistory{}
var trades []AuthenticatedTradeHistory
return trades, l.SendAuthenticatedHTTPRequest(lakeBTCGetTrades, params, &trades)
}
// GetExternalAccounts returns your external accounts WARNING: Only for BTC!
func (l *LakeBTC) GetExternalAccounts() ([]ExternalAccounts, error) {
resp := []ExternalAccounts{}
var resp []ExternalAccounts
return resp, l.SendAuthenticatedHTTPRequest(lakeBTCGetExternalAccounts, "", &resp)
}

View File

@@ -461,7 +461,7 @@ func (l *LocalBitcoins) DeleteInvoice() (Invoice, error) {
// GetNotifications returns recent notifications.
func (l *LocalBitcoins) GetNotifications() ([]NotificationInfo, error) {
resp := []NotificationInfo{}
var resp []NotificationInfo
return resp, l.SendAuthenticatedHTTPRequest(http.MethodPost, localbitcoinsAPIGetNotification, nil, &resp)
}
@@ -668,7 +668,7 @@ func (l *LocalBitcoins) GetTradableCurrencies() ([]string, error) {
// updated every 15 minutes.
func (l *LocalBitcoins) GetTrades(currency string, values url.Values) ([]Trade, error) {
path := common.EncodeURLValues(fmt.Sprintf("%s/%s/trades.json", l.APIUrl+localbitcoinsAPIBitcoincharts, currency), values)
result := []Trade{}
var result []Trade
return result, l.SendHTTPRequest(path, &result)
}

View File

@@ -275,7 +275,7 @@ func (o *OKGroup) PlaceMultipleSpotOrders(request []PlaceSpotOrderRequest) (map[
return resp, []error{err}
}
orderErrors := []error{}
var orderErrors []error
for currency, orderResponse := range resp {
for _, order := range orderResponse {
if !order.Result {
@@ -283,9 +283,6 @@ func (o *OKGroup) PlaceMultipleSpotOrders(request []PlaceSpotOrderRequest) (map[
}
}
}
if len(orderErrors) == 0 {
orderErrors = nil
}
return resp, orderErrors
}
@@ -475,7 +472,7 @@ func (o *OKGroup) PlaceMultipleMarginOrders(request []PlaceSpotOrderRequest) (ma
return resp, []error{err}
}
orderErrors := []error{}
var orderErrors []error
for currency, orderResponse := range resp {
for _, order := range orderResponse {
if !order.Result {
@@ -483,9 +480,6 @@ func (o *OKGroup) PlaceMultipleMarginOrders(request []PlaceSpotOrderRequest) (ma
}
}
}
if len(orderErrors) == 0 {
orderErrors = nil
}
return resp, orderErrors
}
@@ -508,7 +502,7 @@ func (o *OKGroup) CancelMultipleMarginOrders(request CancelMultipleSpotOrdersReq
return resp, []error{err}
}
orderErrors := []error{}
var orderErrors []error
for currency, orderResponse := range resp {
for _, order := range orderResponse {
if !order.Result {
@@ -516,9 +510,6 @@ func (o *OKGroup) CancelMultipleMarginOrders(request CancelMultipleSpotOrdersReq
}
}
}
if len(orderErrors) == 0 {
orderErrors = nil
}
return resp, orderErrors
}

View File

@@ -46,7 +46,7 @@ func DeleteOrder(orderID int) bool {
// GetOrdersByExchange returns order pointer grouped by exchange
func GetOrdersByExchange(exchange string) []*Order {
orders := []*Order{}
var orders []*Order
for i := range Orders {
if Orders[i].Exchange == exchange {
orders = append(orders, Orders[i])

View File

@@ -248,7 +248,7 @@ func (p *Poloniex) GetTradeHistory(currencyPair, start, end string) ([]TradeHist
vals.Set("end", end)
}
resp := []TradeHistory{}
var resp []TradeHistory
path := fmt.Sprintf("%s/public?command=returnTradeHistory&%s", p.APIUrl, vals.Encode())
return resp, p.SendHTTPRequest(path, &resp)
@@ -271,7 +271,7 @@ func (p *Poloniex) GetChartData(currencyPair, start, end, period string) ([]Char
vals.Set("period", period)
}
resp := []ChartData{}
var resp []ChartData
path := fmt.Sprintf("%s/public?command=returnChartData&%s", p.APIUrl, vals.Encode())
err := p.SendHTTPRequest(path, &resp)
@@ -822,7 +822,7 @@ func (p *Poloniex) GetLendingHistory(start, end string) ([]LendingHistory, error
vals.Set("end", end)
}
resp := []LendingHistory{}
var resp []LendingHistory
err := p.SendAuthenticatedHTTPRequest(http.MethodPost,
poloniexLendingHistory,
vals,

View File

@@ -321,7 +321,7 @@ func (z *ZB) GetSpotKline(arg KlinesRequestParams) (KLineResponse, error) {
res.MoneyType = rawKlines["moneyType"].(string)
rawKlineDatasString, _ := json.Marshal(rawKlines["data"].([]interface{}))
rawKlineDatas := [][]interface{}{}
var rawKlineDatas [][]interface{}
if err := json.Unmarshal(rawKlineDatasString, &rawKlineDatas); err != nil {
return res, errors.New("zb rawKlines unmarshal failed")
}

View File

@@ -264,7 +264,7 @@ func TestGetSpecificOrderbook(t *testing.T) {
LoadExchange("Bitstamp", false, nil)
bids := []orderbook.Item{}
var bids []orderbook.Item
bids = append(bids, orderbook.Item{Price: 1000, Amount: 1})
base := orderbook.Base{
@@ -329,7 +329,7 @@ func TestGetSpecificTicker(t *testing.T) {
func TestGetCollatedExchangeAccountInfoByCoin(t *testing.T) {
SetupTestHelpers(t)
exchangeInfo := []exchange.AccountInfo{}
var exchangeInfo []exchange.AccountInfo
var info exchange.AccountInfo
info.Exchange = "Bitfinex"
@@ -383,7 +383,7 @@ func TestGetCollatedExchangeAccountInfoByCoin(t *testing.T) {
func TestGetAccountCurrencyInfoByExchangeName(t *testing.T) {
SetupTestHelpers(t)
exchangeInfo := []exchange.AccountInfo{}
var exchangeInfo []exchange.AccountInfo
var info exchange.AccountInfo
info.Exchange = "Bitfinex"
info.Accounts = append(info.Accounts,