mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-28 15:10:32 +00:00
build/ci: Update Go to v1.24, golangci-lint to v1.64.6 and fix issues (#1804)
* build/ci: Update Go to v1.24, golangci-lint to v1.64.5 and fix issues * Address shazbert's nitters * linter/config: Fix new linter issue and use versionSize const * Address gk's nitters and fix additional linter issue after rebase * Address glorious nits * staticcheck: Fix additional linter issues after upgrading to Go 1.24.1 and golangci-lint v1.64.6 Also addresses nits * Improve testing, assertify usage and use common.ErrParsingWSField * TestCreateNewStrategy: Replace must > should wording
This commit is contained in:
@@ -451,7 +451,7 @@ func (bi *Binanceus) GetSpotKline(ctx context.Context, arg *KlinesRequestParams)
|
||||
params.Set("symbol", symbol)
|
||||
params.Set("interval", arg.Interval)
|
||||
if arg.Limit != 0 {
|
||||
params.Set("limit", strconv.FormatInt(arg.Limit, 10))
|
||||
params.Set("limit", strconv.FormatUint(arg.Limit, 10))
|
||||
}
|
||||
if !arg.StartTime.IsZero() && arg.StartTime.Unix() != 0 {
|
||||
params.Set("startTime", strconv.FormatInt((arg.StartTime).UnixMilli(), 10))
|
||||
@@ -634,16 +634,16 @@ func (bi *Binanceus) GetAccount(ctx context.Context) (*Account, error) {
|
||||
}
|
||||
|
||||
// GetUserAccountStatus to fetch account status detail.
|
||||
func (bi *Binanceus) GetUserAccountStatus(ctx context.Context, recvWindow uint) (*AccountStatusResponse, error) {
|
||||
func (bi *Binanceus) GetUserAccountStatus(ctx context.Context, recvWindow uint64) (*AccountStatusResponse, error) {
|
||||
var resp AccountStatusResponse
|
||||
params := url.Values{}
|
||||
timestamp := time.Now().UnixMilli()
|
||||
params.Set("timestamp", strconv.Itoa(int(timestamp)))
|
||||
params.Set("timestamp", strconv.FormatInt(timestamp, 10))
|
||||
if recvWindow > 0 && recvWindow < 60000 {
|
||||
if recvWindow < 2000 {
|
||||
recvWindow += 1500
|
||||
}
|
||||
params.Set("recvWindow", strconv.Itoa(int(recvWindow)))
|
||||
params.Set("recvWindow", strconv.FormatUint(recvWindow, 10))
|
||||
}
|
||||
|
||||
return &resp,
|
||||
@@ -657,7 +657,7 @@ func (bi *Binanceus) GetUserAccountStatus(ctx context.Context, recvWindow uint)
|
||||
}
|
||||
|
||||
// GetUserAPITradingStatus to fetch account API trading status details.
|
||||
func (bi *Binanceus) GetUserAPITradingStatus(ctx context.Context, recvWindow uint) (*TradeStatus, error) {
|
||||
func (bi *Binanceus) GetUserAPITradingStatus(ctx context.Context, recvWindow uint64) (*TradeStatus, error) {
|
||||
type response struct {
|
||||
Success bool `json:"success"`
|
||||
TC TradeStatus `json:"status"`
|
||||
@@ -665,11 +665,11 @@ func (bi *Binanceus) GetUserAPITradingStatus(ctx context.Context, recvWindow uin
|
||||
var resp response
|
||||
params := url.Values{}
|
||||
timestamp := time.Now().UnixMilli()
|
||||
params.Set("timestamp", strconv.Itoa(int(timestamp)))
|
||||
params.Set("timestamp", strconv.FormatInt(timestamp, 10))
|
||||
if recvWindow > 0 && recvWindow < 2000 {
|
||||
recvWindow += 1500
|
||||
}
|
||||
params.Set("recvWindow", strconv.Itoa(int(recvWindow)))
|
||||
params.Set("recvWindow", strconv.FormatUint(recvWindow, 10))
|
||||
return &resp.TC,
|
||||
bi.SendAuthHTTPRequest(ctx,
|
||||
exchange.RestSpotSupplementary,
|
||||
@@ -743,7 +743,7 @@ func calculateTradingFee(purchasePrice, amount, multiplier float64) float64 {
|
||||
}
|
||||
|
||||
// GetTradeFee to fetch trading fees.
|
||||
func (bi *Binanceus) GetTradeFee(ctx context.Context, recvWindow uint, symbol string) (TradeFeeList, error) {
|
||||
func (bi *Binanceus) GetTradeFee(ctx context.Context, recvWindow uint64, symbol string) (TradeFeeList, error) {
|
||||
timestamp := time.Now().UnixMilli()
|
||||
params := url.Values{}
|
||||
var resp TradeFeeList
|
||||
@@ -754,7 +754,7 @@ func (bi *Binanceus) GetTradeFee(ctx context.Context, recvWindow uint, symbol st
|
||||
} else if recvWindow > 60000 {
|
||||
recvWindow = recvWindowSize5000
|
||||
}
|
||||
params.Set("recvWindow", strconv.Itoa(int(recvWindow)))
|
||||
params.Set("recvWindow", strconv.FormatUint(recvWindow, 10))
|
||||
}
|
||||
if symbol != "" {
|
||||
params.Set("symbol", symbol)
|
||||
@@ -773,16 +773,16 @@ func (bi *Binanceus) GetTradeFee(ctx context.Context, recvWindow uint, symbol st
|
||||
//
|
||||
// INPUTS:
|
||||
// asset: string , startTime & endTime unix time in Milli seconds, recvWindow(duration in milli seconds > 2000 to < 6000)
|
||||
func (bi *Binanceus) GetAssetDistributionHistory(ctx context.Context, asset string, startTime, endTime uint64, recvWindow uint) (*AssetDistributionHistories, error) {
|
||||
func (bi *Binanceus) GetAssetDistributionHistory(ctx context.Context, asset string, startTime, endTime int64, recvWindow uint64) (*AssetDistributionHistories, error) {
|
||||
params := url.Values{}
|
||||
timestamp := time.Now().UnixMilli()
|
||||
var resp AssetDistributionHistories
|
||||
params.Set("timestamp", strconv.Itoa(int(timestamp)))
|
||||
if startTime > 0 && time.UnixMilli(int64(startTime)).Before(time.Now()) {
|
||||
params.Set("startTime", strconv.Itoa(int(startTime)))
|
||||
params.Set("timestamp", strconv.FormatInt(timestamp, 10))
|
||||
if startTime > 0 && time.UnixMilli(startTime).Before(time.Now()) {
|
||||
params.Set("startTime", strconv.FormatInt(startTime, 10))
|
||||
}
|
||||
if startTime > 0 {
|
||||
params.Set("endTime", strconv.Itoa(int(endTime)))
|
||||
params.Set("endTime", strconv.FormatInt(endTime, 10))
|
||||
}
|
||||
if recvWindow > 0 && recvWindow < 60000 {
|
||||
if recvWindow < 2000 {
|
||||
@@ -790,7 +790,7 @@ func (bi *Binanceus) GetAssetDistributionHistory(ctx context.Context, asset stri
|
||||
} else if recvWindow > 6000 {
|
||||
recvWindow = recvWindowSize5000
|
||||
}
|
||||
params.Set("recvWindow", strconv.Itoa(int(recvWindow)))
|
||||
params.Set("recvWindow", strconv.FormatUint(recvWindow, 10))
|
||||
}
|
||||
|
||||
if asset != "" {
|
||||
@@ -825,7 +825,7 @@ func (bi *Binanceus) QuickDisableCryptoWithdrawal(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// GetUsersSpotAssetSnapshot retrieves a snapshot of list of assets in the account.
|
||||
func (bi *Binanceus) GetUsersSpotAssetSnapshot(ctx context.Context, startTime, endTime time.Time, limit, offset uint) (*SpotAssetsSnapshotResponse, error) {
|
||||
func (bi *Binanceus) GetUsersSpotAssetSnapshot(ctx context.Context, startTime, endTime time.Time, limit, offset uint64) (*SpotAssetsSnapshotResponse, error) {
|
||||
params := url.Values{}
|
||||
params.Set("type", "SPOT")
|
||||
params.Set("timestamp", strconv.FormatInt(time.Now().UnixMilli(), 10))
|
||||
@@ -838,10 +838,10 @@ func (bi *Binanceus) GetUsersSpotAssetSnapshot(ctx context.Context, startTime, e
|
||||
}
|
||||
}
|
||||
if limit > 0 {
|
||||
params.Set("limit", strconv.Itoa(int(limit)))
|
||||
params.Set("limit", strconv.FormatUint(limit, 10))
|
||||
}
|
||||
if offset > 0 {
|
||||
params.Set("offset", strconv.Itoa(int(offset)))
|
||||
params.Set("offset", strconv.FormatUint(offset, 10))
|
||||
}
|
||||
var resp SpotAssetsSnapshotResponse
|
||||
return &resp, bi.SendAuthHTTPRequest(ctx, exchange.RestSpotSupplementary,
|
||||
@@ -850,7 +850,7 @@ func (bi *Binanceus) GetUsersSpotAssetSnapshot(ctx context.Context, startTime, e
|
||||
}
|
||||
|
||||
// GetSubaccountInformation to fetch your sub-account list.
|
||||
func (bi *Binanceus) GetSubaccountInformation(ctx context.Context, page, limit uint, status, email string) ([]SubAccount, error) {
|
||||
func (bi *Binanceus) GetSubaccountInformation(ctx context.Context, page, limit uint64, status, email string) ([]SubAccount, error) {
|
||||
params := url.Values{}
|
||||
type response struct {
|
||||
Success bool `json:"success"`
|
||||
@@ -865,10 +865,10 @@ func (bi *Binanceus) GetSubaccountInformation(ctx context.Context, page, limit u
|
||||
params.Set("status", status)
|
||||
}
|
||||
if page != 0 {
|
||||
params.Set("page", strconv.Itoa(int(page)))
|
||||
params.Set("page", strconv.FormatUint(page, 10))
|
||||
}
|
||||
if limit != 0 {
|
||||
params.Set("limit", strconv.Itoa(int(limit)))
|
||||
params.Set("limit", strconv.FormatUint(limit, 10))
|
||||
}
|
||||
timestamp := time.Now().UnixMilli()
|
||||
params.Set("timestamp", strconv.FormatInt(timestamp, 10))
|
||||
@@ -882,38 +882,34 @@ func (bi *Binanceus) GetSubaccountInformation(ctx context.Context, page, limit u
|
||||
}
|
||||
|
||||
// GetSubaccountTransferHistory to fetch sub-account asset transfer history.
|
||||
func (bi *Binanceus) GetSubaccountTransferHistory(ctx context.Context,
|
||||
email string,
|
||||
startTime uint64,
|
||||
endTime uint64,
|
||||
page, limit int) ([]TransferHistory, error) {
|
||||
timestamp := time.Now().UnixMilli()
|
||||
params := url.Values{}
|
||||
type response struct {
|
||||
Success bool `json:"success"`
|
||||
Transfers []TransferHistory `json:"transfers"`
|
||||
}
|
||||
var resp response
|
||||
func (bi *Binanceus) GetSubaccountTransferHistory(ctx context.Context, email string, startTime, endTime, page, limit int64) ([]TransferHistory, error) {
|
||||
if !common.MatchesEmailPattern(email) {
|
||||
return nil, errNotValidEmailAddress
|
||||
}
|
||||
|
||||
params := url.Values{}
|
||||
params.Set("email", email)
|
||||
params.Set("timestamp", strconv.Itoa(int(timestamp)))
|
||||
params.Set("timestamp", strconv.FormatInt(time.Now().UnixMilli(), 10))
|
||||
if page != 0 {
|
||||
params.Set("page", strconv.Itoa(page))
|
||||
params.Set("page", strconv.FormatInt(page, 10))
|
||||
}
|
||||
if limit != 0 {
|
||||
params.Set("limit", strconv.Itoa(limit))
|
||||
params.Set("limit", strconv.FormatInt(limit, 10))
|
||||
}
|
||||
startTimeT := time.UnixMilli(int64(startTime))
|
||||
endTimeT := time.UnixMilli(int64(endTime))
|
||||
startTimeT := time.UnixMilli(startTime)
|
||||
endTimeT := time.UnixMilli(endTime)
|
||||
|
||||
hundredDayBefore := time.Now().Add(-time.Hour * 24 * 100).Truncate(time.Hour)
|
||||
if !(startTimeT.Before(hundredDayBefore)) || startTimeT.Before(time.Now()) {
|
||||
params.Set("startTime", strconv.Itoa(int(startTime)))
|
||||
params.Set("startTime", strconv.FormatInt(startTime, 10))
|
||||
}
|
||||
if !(endTimeT.Before(hundredDayBefore)) || endTimeT.Before(time.Now()) {
|
||||
params.Set("startTime", strconv.Itoa(int(endTime)))
|
||||
params.Set("endTime", strconv.FormatInt(endTime, 10))
|
||||
}
|
||||
|
||||
var resp struct {
|
||||
Success bool `json:"success"`
|
||||
Transfers []TransferHistory `json:"transfers"`
|
||||
}
|
||||
return resp.Transfers, bi.SendAuthHTTPRequest(ctx,
|
||||
exchange.RestSpotSupplementary,
|
||||
@@ -1083,7 +1079,7 @@ func (bi *Binanceus) GetOrder(ctx context.Context, arg *OrderRequestParams) (*Or
|
||||
}
|
||||
params.Set("symbol", strings.ToUpper(arg.Symbol))
|
||||
if arg.OrderID > 0 {
|
||||
params.Set("orderId", strconv.Itoa(int(arg.OrderID)))
|
||||
params.Set("orderId", strconv.FormatUint(arg.OrderID, 10))
|
||||
}
|
||||
timestamp := time.Now().UnixMilli()
|
||||
params.Set("timestamp", strconv.Itoa(int(timestamp)))
|
||||
@@ -1173,16 +1169,16 @@ func (bi *Binanceus) GetTrades(ctx context.Context, arg *GetTradesParams) ([]Tra
|
||||
params.Set("symbol", arg.Symbol)
|
||||
params.Set("timestamp", strconv.Itoa(int(time.Now().UnixMilli())))
|
||||
if arg.RecvWindow > 3000 {
|
||||
params.Set("recvWindow", strconv.Itoa(int(arg.RecvWindow)))
|
||||
params.Set("recvWindow", strconv.FormatUint(arg.RecvWindow, 10))
|
||||
}
|
||||
if arg.StartTime != nil {
|
||||
params.Set("startTime", strconv.Itoa(int(arg.StartTime.UnixMilli())))
|
||||
params.Set("startTime", strconv.FormatInt(arg.StartTime.UnixMilli(), 10))
|
||||
}
|
||||
if arg.EndTime != nil {
|
||||
params.Set("endTime", strconv.Itoa(int(arg.EndTime.UnixMilli())))
|
||||
params.Set("endTime", strconv.FormatInt(arg.EndTime.UnixMilli(), 10))
|
||||
}
|
||||
if arg.FromID > 0 {
|
||||
params.Set("fromId", strconv.Itoa(int(arg.FromID)))
|
||||
params.Set("fromId", strconv.FormatUint(arg.FromID, 10))
|
||||
}
|
||||
if arg.Limit > 0 && arg.Limit < 1000 {
|
||||
params.Set("limit", strconv.FormatUint(arg.Limit, 10))
|
||||
@@ -1230,7 +1226,7 @@ func (bi *Binanceus) CreateNewOCOOrder(ctx context.Context, arg *OCOOrderInputPa
|
||||
params.Set("newOrderRespType", arg.NewOrderRespType)
|
||||
}
|
||||
if arg.RecvWindow > 200 {
|
||||
params.Set("recvWindow", strconv.Itoa(int(arg.RecvWindow)))
|
||||
params.Set("recvWindow", strconv.FormatUint(arg.RecvWindow, 10))
|
||||
} else {
|
||||
params.Set("recvWindow", "6000")
|
||||
}
|
||||
@@ -1308,7 +1304,7 @@ func (bi *Binanceus) CancelOCOOrder(ctx context.Context, arg *OCOOrdersDeleteReq
|
||||
params.Set("timestamp", strconv.FormatInt(time.Now().UnixMilli(), 10))
|
||||
switch {
|
||||
case arg.OrderListID > 0:
|
||||
params.Set("orderListId", strconv.Itoa(int(arg.OrderListID)))
|
||||
params.Set("orderListId", strconv.FormatUint(arg.OrderListID, 10))
|
||||
case arg.ListClientOrderID != "":
|
||||
params.Set("listClientOrderId", arg.ListClientOrderID)
|
||||
default:
|
||||
|
||||
@@ -192,7 +192,7 @@ type OrderBook struct {
|
||||
type KlinesRequestParams struct {
|
||||
Symbol currency.Pair // Required field; example LTCBTC, BTCUSDT
|
||||
Interval string // Time interval period
|
||||
Limit int64 // Default 500; max 500.
|
||||
Limit uint64 // Default 500; max 500.
|
||||
StartTime time.Time
|
||||
EndTime time.Time
|
||||
}
|
||||
|
||||
@@ -618,7 +618,7 @@ func (bi *Binanceus) GetOrderInfo(ctx context.Context, orderID string, pair curr
|
||||
return nil, err
|
||||
}
|
||||
|
||||
orderIDInt, err := strconv.ParseInt(orderID, 10, 64)
|
||||
orderIDInt, err := strconv.ParseUint(orderID, 10, 64)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid orderID %w", err)
|
||||
}
|
||||
@@ -632,7 +632,7 @@ func (bi *Binanceus) GetOrderInfo(ctx context.Context, orderID string, pair curr
|
||||
var orderType order.Type
|
||||
resp, err := bi.GetOrder(ctx, &OrderRequestParams{
|
||||
Symbol: symbolValue,
|
||||
OrderID: uint64(orderIDInt),
|
||||
OrderID: orderIDInt,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -653,7 +653,7 @@ func (bi *Binanceus) GetOrderInfo(ctx context.Context, orderID string, pair curr
|
||||
return &order.Detail{
|
||||
Amount: resp.OrigQty,
|
||||
Exchange: bi.Name,
|
||||
OrderID: strconv.FormatInt(int64(resp.OrderID), 10),
|
||||
OrderID: strconv.FormatUint(resp.OrderID, 10),
|
||||
ClientOrderID: resp.ClientOrderID,
|
||||
Side: orderSide,
|
||||
Type: orderType,
|
||||
@@ -764,7 +764,7 @@ func (bi *Binanceus) GetActiveOrders(ctx context.Context, getOrdersRequest *orde
|
||||
Amount: resp[x].OrigQty,
|
||||
Date: resp[x].Time,
|
||||
Exchange: bi.Name,
|
||||
OrderID: strconv.FormatInt(int64(resp[x].OrderID), 10),
|
||||
OrderID: strconv.FormatUint(resp[x].OrderID, 10),
|
||||
ClientOrderID: resp[x].ClientOrderID,
|
||||
Side: orderSide,
|
||||
Type: orderType,
|
||||
|
||||
@@ -159,7 +159,7 @@ func (a *NewOrderResponse) UnmarshalJSON(data []byte) error {
|
||||
func (a *TransferHistory) UnmarshalJSON(data []byte) error {
|
||||
type Alias TransferHistory
|
||||
aux := &struct {
|
||||
TimeStamp uint64 `json:"time"`
|
||||
TimeStamp int64 `json:"time"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
@@ -167,8 +167,8 @@ func (a *TransferHistory) UnmarshalJSON(data []byte) error {
|
||||
if err := json.Unmarshal(data, aux); err != nil {
|
||||
return err
|
||||
}
|
||||
if aux.TimeStamp == 0 {
|
||||
a.TimeStamp = time.UnixMilli(int64(aux.TimeStamp))
|
||||
if aux.TimeStamp > 0 {
|
||||
a.TimeStamp = time.UnixMilli(aux.TimeStamp)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -177,7 +177,7 @@ func (a *TransferHistory) UnmarshalJSON(data []byte) error {
|
||||
func (a *ExchangeInfo) UnmarshalJSON(data []byte) error {
|
||||
type Alias ExchangeInfo
|
||||
chil := &struct {
|
||||
Servertime uint64 `json:"serverTime"`
|
||||
Servertime int64 `json:"serverTime"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(a),
|
||||
@@ -186,7 +186,7 @@ func (a *ExchangeInfo) UnmarshalJSON(data []byte) error {
|
||||
return er
|
||||
}
|
||||
if chil.Servertime > 0 {
|
||||
a.ServerTime = time.UnixMilli(int64(chil.Servertime))
|
||||
a.ServerTime = time.UnixMilli(chil.Servertime)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user