linter: Enable gofumpt and run against codebase (#1848)

* linter: Enable gofumpt and run against codebase

* Address shazbert's nits

* gofumpt: Fix issues after rebase
This commit is contained in:
Adrian Gallagher
2025-03-18 10:23:16 +11:00
committed by GitHub
parent 748ed71455
commit f5faca2eb2
189 changed files with 1541 additions and 1104 deletions

View File

@@ -638,7 +638,7 @@ func (b *Bitfinex) GetTickerBatch(ctx context.Context) (map[string]*Ticker, erro
}
var tickErrs error
var tickers = make(map[string]*Ticker)
tickers := make(map[string]*Ticker)
for _, tickResp := range response {
symbol, ok := tickResp[0].(string)
if !ok {
@@ -841,7 +841,7 @@ func (b *Bitfinex) GetTrades(ctx context.Context, currencyPair string, limit, ti
// Values can contain limit amounts for both the asks and bids - Example
// "len" = 100
func (b *Bitfinex) GetOrderbook(ctx context.Context, symbol, precision string, limit int64) (Orderbook, error) {
var u = url.Values{}
u := url.Values{}
if limit > 0 {
u.Set("len", strconv.FormatInt(limit, 10))
}
@@ -1000,7 +1000,7 @@ func (b *Bitfinex) GetCandles(ctx context.Context, symbol, timeFrame string, sta
fundingPeriod = ":p30"
}
var path = bitfinexAPIVersion2 +
path := bitfinexAPIVersion2 +
bitfinexCandles +
":" +
timeFrame +
@@ -2071,7 +2071,8 @@ func (b *Bitfinex) SendHTTPRequest(ctx context.Context, ep exchange.URL, path st
Result: result,
Verbose: b.Verbose,
HTTPDebugging: b.HTTPDebugging,
HTTPRecording: b.HTTPRecording}
HTTPRecording: b.HTTPRecording,
}
return b.SendPayload(ctx, e, func() (*request.Item, error) {
return item, nil
@@ -2126,7 +2127,8 @@ func (b *Bitfinex) SendAuthenticatedHTTPRequest(ctx context.Context, ep exchange
NonceEnabled: true,
Verbose: b.Verbose,
HTTPDebugging: b.HTTPDebugging,
HTTPRecording: b.HTTPRecording}, nil
HTTPRecording: b.HTTPRecording,
}, nil
}, request.AuthenticatedRequest)
}
@@ -2203,7 +2205,7 @@ func (b *Bitfinex) GetFee(ctx context.Context, feeBuilder *exchange.FeeBuilder)
return 0, err
}
case exchange.CryptocurrencyDepositFee:
//TODO: fee is charged when < $1000USD is transferred, need to infer value in some way
// TODO: fee is charged when < $1000USD is transferred, need to infer value in some way
fee = 0
case exchange.CryptocurrencyWithdrawalFee:
acc, err := b.GetWithdrawalFees(ctx)

View File

@@ -39,8 +39,10 @@ const (
canManipulateRealOrders = false
)
var b *Bitfinex
var btcusdPair = currency.NewPair(currency.BTC, currency.USD)
var (
b *Bitfinex
btcusdPair = currency.NewPair(currency.BTC, currency.USD)
)
func TestMain(m *testing.M) {
b = new(Bitfinex)
@@ -791,7 +793,7 @@ func setFeeBuilder() *exchange.FeeBuilder {
// TestGetFeeByTypeOfflineTradeFee logic test
func TestGetFeeByTypeOfflineTradeFee(t *testing.T) {
var feeBuilder = setFeeBuilder()
feeBuilder := setFeeBuilder()
_, err := b.GetFeeByType(context.Background(), feeBuilder)
if err != nil {
t.Fatal(err)
@@ -808,7 +810,7 @@ func TestGetFeeByTypeOfflineTradeFee(t *testing.T) {
}
func TestGetFee(t *testing.T) {
var feeBuilder = setFeeBuilder()
feeBuilder := setFeeBuilder()
t.Parallel()
if sharedtestvalues.AreAPICredentialsSet(b) {
@@ -883,7 +885,7 @@ func TestFormatWithdrawPermissions(t *testing.T) {
func TestGetActiveOrders(t *testing.T) {
t.Parallel()
sharedtestvalues.SkipTestIfCredentialsUnset(t, b)
var getOrdersRequest = order.MultiOrderRequest{
getOrdersRequest := order.MultiOrderRequest{
Type: order.AnyType,
AssetType: asset.Spot,
Side: order.AnySide,
@@ -900,7 +902,7 @@ func TestGetActiveOrders(t *testing.T) {
func TestGetOrderHistory(t *testing.T) {
t.Parallel()
sharedtestvalues.SkipTestIfCredentialsUnset(t, b)
var getOrdersRequest = order.MultiOrderRequest{
getOrdersRequest := order.MultiOrderRequest{
Type: order.AnyType,
AssetType: asset.Spot,
Side: order.AnySide,
@@ -916,7 +918,7 @@ func TestGetOrderHistory(t *testing.T) {
func TestSubmitOrder(t *testing.T) {
t.Parallel()
sharedtestvalues.SkipTestIfCannotManipulateOrders(t, b, canManipulateRealOrders)
var orderSubmission = &order.Submit{
orderSubmission := &order.Submit{
Exchange: b.Name,
Pair: currency.Pair{
Delimiter: "_",
@@ -948,7 +950,7 @@ func TestCancelExchangeOrder(t *testing.T) {
sharedtestvalues.SkipTestIfCannotManipulateOrders(t, b, canManipulateRealOrders)
currencyPair := currency.NewPair(currency.LTC, currency.BTC)
var orderCancellation = &order.Cancel{
orderCancellation := &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
@@ -970,7 +972,7 @@ func TestCancelAllExchangeOrders(t *testing.T) {
sharedtestvalues.SkipTestIfCannotManipulateOrders(t, b, canManipulateRealOrders)
currencyPair := currency.NewPair(currency.LTC, currency.BTC)
var orderCancellation = &order.Cancel{
orderCancellation := &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
@@ -1036,7 +1038,7 @@ func TestWithdrawFiat(t *testing.T) {
t.Parallel()
sharedtestvalues.SkipTestIfCannotManipulateOrders(t, b, canManipulateRealOrders)
var withdrawFiatRequest = withdraw.Request{
withdrawFiatRequest := withdraw.Request{
Amount: -1,
Currency: currency.USD,
Description: "WITHDRAW IT ALL",
@@ -1058,7 +1060,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
t.Parallel()
sharedtestvalues.SkipTestIfCannotManipulateOrders(t, b, canManipulateRealOrders)
var withdrawFiatRequest = withdraw.Request{
withdrawFiatRequest := withdraw.Request{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",

View File

@@ -54,13 +54,17 @@ type WalletDataV2 struct {
}
// AcceptedOrderType defines the accepted market types, exchange strings denote non-contract order types.
var AcceptedOrderType = []string{"market", "limit", "stop", "trailing-stop",
var AcceptedOrderType = []string{
"market", "limit", "stop", "trailing-stop",
"fill-or-kill", "exchange market", "exchange limit", "exchange stop",
"exchange trailing-stop", "exchange fill-or-kill"}
"exchange trailing-stop", "exchange fill-or-kill",
}
// AcceptedWalletNames defines different wallets supported by the exchange
var AcceptedWalletNames = []string{"trading", "exchange", "deposit", "margin",
"funding"}
var AcceptedWalletNames = []string{
"trading", "exchange", "deposit", "margin",
"funding",
}
type acceptableMethodStore struct {
a map[string][]string

View File

@@ -314,7 +314,8 @@ func (b *Bitfinex) UpdateTickers(ctx context.Context, a asset.Item) error {
Volume: val.Volume,
Pair: pair,
AssetType: a,
ExchangeName: b.Name})
ExchangeName: b.Name,
})
if err != nil {
errs = common.AppendError(errs, err)
}
@@ -354,7 +355,7 @@ func (b *Bitfinex) UpdateOrderbook(ctx context.Context, p currency.Pair, assetTy
return o, fmt.Errorf("%w %v", asset.ErrNotSupported, assetType)
}
b.appendOptionalDelimiter(&fPair)
var prefix = "t"
prefix := "t"
if assetType == asset.MarginFunding {
prefix = "f"
}
@@ -419,7 +420,7 @@ func (b *Bitfinex) UpdateAccountInfo(ctx context.Context, assetType asset.Item)
return response, err
}
var Accounts = []account.SubAccount{
Accounts := []account.SubAccount{
{ID: "deposit", AssetType: assetType},
{ID: "exchange", AssetType: assetType},
{ID: "trading", AssetType: assetType},