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

@@ -55,7 +55,8 @@ var errSymbolIsEmpty = errors.New("symbol cannot be empty")
// Bithumb is the overarching type across the Bithumb package
type Bithumb struct {
exchange.Base
obm orderbookManager
location *time.Location
obm orderbookManager
}
// GetTradablePairs returns a list of tradable currencies
@@ -207,7 +208,7 @@ func (b *Bithumb) GetAccountInformation(ctx context.Context, orderCurrency, paym
// GetAccountBalance returns customer wallet information
func (b *Bithumb) GetAccountBalance(ctx context.Context, c string) (FullBalance, error) {
var response Balance
var fullBalance = FullBalance{
fullBalance := FullBalance{
make(map[string]float64),
make(map[string]float64),
make(map[string]float64),
@@ -596,7 +597,8 @@ func (b *Bithumb) SendAuthenticatedHTTPRequest(ctx context.Context, ep exchange.
NonceEnabled: true,
Verbose: b.Verbose,
HTTPDebugging: b.HTTPDebugging,
HTTPRecording: b.HTTPRecording}, nil
HTTPRecording: b.HTTPRecording,
}, nil
}, request.AuthenticatedRequest)
if err != nil {
return err

View File

@@ -286,7 +286,7 @@ func setFeeBuilder() *exchange.FeeBuilder {
// TestGetFeeByTypeOfflineTradeFee logic test
func TestGetFeeByTypeOfflineTradeFee(t *testing.T) {
t.Parallel()
var feeBuilder = setFeeBuilder()
feeBuilder := setFeeBuilder()
_, err := b.GetFeeByType(context.Background(), feeBuilder)
require.NoError(t, err, "GetFeeByType must not error")
@@ -299,7 +299,7 @@ func TestGetFeeByTypeOfflineTradeFee(t *testing.T) {
func TestGetFee(t *testing.T) {
t.Parallel()
var feeBuilder = setFeeBuilder()
feeBuilder := setFeeBuilder()
// CryptocurrencyTradeFee Basic
_, err := b.GetFee(feeBuilder)
require.NoError(t, err, "GetFee must not error")
@@ -361,7 +361,7 @@ func TestGetActiveOrders(t *testing.T) {
t.Parallel()
sharedtestvalues.SkipTestIfCredentialsUnset(t, b)
var getOrdersRequest = order.MultiOrderRequest{
getOrdersRequest := order.MultiOrderRequest{
Type: order.AnyType,
Side: order.Sell,
AssetType: asset.Spot,
@@ -375,7 +375,7 @@ 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,
@@ -393,7 +393,7 @@ func TestSubmitOrder(t *testing.T) {
t.Parallel()
sharedtestvalues.SkipTestIfCredentialsUnset(t, b, canManipulateRealOrders)
var orderSubmission = &order.Submit{
orderSubmission := &order.Submit{
Exchange: b.Name,
Pair: currency.Pair{
Base: currency.BTC,
@@ -415,7 +415,7 @@ func TestCancelExchangeOrder(t *testing.T) {
sharedtestvalues.SkipTestIfCredentialsUnset(t, b, canManipulateRealOrders)
currencyPair := currency.NewPair(currency.LTC, currency.BTC)
var orderCancellation = &order.Cancel{
orderCancellation := &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
@@ -432,7 +432,7 @@ func TestCancelAllExchangeOrders(t *testing.T) {
sharedtestvalues.SkipTestIfCredentialsUnset(t, b, canManipulateRealOrders)
currencyPair := currency.NewPair(currency.LTC, currency.BTC)
var orderCancellation = &order.Cancel{
orderCancellation := &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
@@ -483,7 +483,7 @@ func TestWithdrawFiat(t *testing.T) {
t.Parallel()
sharedtestvalues.SkipTestIfCredentialsUnset(t, b, canManipulateRealOrders)
var withdrawFiatRequest = withdraw.Request{
withdrawFiatRequest := withdraw.Request{
Type: withdraw.Fiat,
Exchange: b.Name,
Fiat: withdraw.FiatRequest{
@@ -518,7 +518,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
t.Parallel()
sharedtestvalues.SkipTestIfCredentialsUnset(t, b, canManipulateRealOrders)
var withdrawFiatRequest = withdraw.Request{}
withdrawFiatRequest := withdraw.Request{}
_, err := b.WithdrawFiatFundsToInternationalBank(context.Background(),
&withdrawFiatRequest)
assert.ErrorIs(t, err, common.ErrFunctionNotSupported)

View File

@@ -28,10 +28,6 @@ const (
tradeTimeLayout = time.DateTime + ".000000"
)
var (
location *time.Location
)
var defaultSubscriptions = subscription.List{
{Enabled: true, Asset: asset.Spot, Channel: subscription.TickerChannel, Interval: kline.ThirtyMin}, // alternatives "1H", "12H", "24H"
{Enabled: true, Asset: asset.Spot, Channel: subscription.OrderbookChannel},
@@ -107,9 +103,7 @@ func (b *Bithumb) wsHandleData(respRaw []byte) error {
return err
}
var lu time.Time
lu, err = time.ParseInLocation(tickerTimeLayout,
tick.Date+tick.Time,
location)
lu, err = time.ParseInLocation(tickerTimeLayout, tick.Date+tick.Time, b.location)
if err != nil {
return err
}
@@ -140,9 +134,7 @@ func (b *Bithumb) wsHandleData(respRaw []byte) error {
toBuffer := make([]trade.Data, len(trades.List))
var lu time.Time
for x := range trades.List {
lu, err = time.ParseInLocation(tradeTimeLayout,
trades.List[x].ContractTime,
location)
lu, err = time.ParseInLocation(tradeTimeLayout, trades.List[x].ContractTime, b.location)
if err != nil {
return err
}

View File

@@ -3,6 +3,7 @@ package bithumb
import (
"errors"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -25,6 +26,7 @@ var (
func TestWsHandleData(t *testing.T) {
t.Parallel()
pairs := currency.Pairs{
currency.Pair{
Base: currency.BTC,
@@ -33,6 +35,7 @@ func TestWsHandleData(t *testing.T) {
}
dummy := Bithumb{
location: time.Local,
Base: exchange.Base{
Name: "dummy",
Features: exchange.Features{
@@ -125,8 +128,10 @@ func TestGenerateSubscriptions(t *testing.T) {
exp := subscription.List{
{Asset: asset.Spot, Channel: subscription.AllTradesChannel, Pairs: p, QualifiedChannel: `{"type":"transaction","symbols":["BTC_KRW","ETH_KRW"]}`},
{Asset: asset.Spot, Channel: subscription.OrderbookChannel, Pairs: p, QualifiedChannel: `{"type":"orderbookdepth","symbols":["BTC_KRW","ETH_KRW"]}`},
{Asset: asset.Spot, Channel: subscription.TickerChannel, Pairs: p, Interval: kline.ThirtyMin,
QualifiedChannel: `{"type":"ticker","symbols":["BTC_KRW","ETH_KRW"],"tickTypes":["30M"]}`},
{
Asset: asset.Spot, Channel: subscription.TickerChannel, Pairs: p, Interval: kline.ThirtyMin,
QualifiedChannel: `{"type":"ticker","symbols":["BTC_KRW","ETH_KRW"],"tickTypes":["30M"]}`,
},
}
testsubs.EqualLists(t, exp, subs)
}

View File

@@ -49,6 +49,11 @@ func (b *Bithumb) SetDefaults() {
log.Errorln(log.ExchangeSys, err)
}
b.location, err = time.LoadLocation("Asia/Seoul")
if err != nil {
log.Errorf(log.ExchangeSys, "Bithumb unable to load time location: %s", err)
}
b.Features = exchange.Features{
Supports: exchange.FeaturesSupported{
REST: true,
@@ -146,11 +151,6 @@ func (b *Bithumb) Setup(exch *config.Exchange) error {
return err
}
location, err = time.LoadLocation("Asia/Seoul")
if err != nil {
return err
}
ePoint, err := b.API.Endpoints.GetURL(exchange.WebsocketSpot)
if err != nil {
return err