modernise: Run new gopls modernise tool against the codebase and fix minor issues (#1826)

* modernise: Run new gopls modernise tool against codebase

* Address shazbert's nits

* apichecker, gctcli: Simplify HTML scraping functions and improve depth limit handling

* refactor: Create minSyncInterval const and update order book limit handling for binance and binanceUS

* refactor: Various slice usage improvements and rename TODO

* tranches: Revert deleteByID changes due to performance decrease

Shazbert was a F1 driver in a past lifetime 🏎️

* tranches: Simply retrieve copy

Thanks to shazbert

* documentation: Sort contributors list by contributions

* tranches: Remove deadcode in deleteByID
This commit is contained in:
Adrian Gallagher
2025-03-21 09:17:10 +11:00
committed by GitHub
parent d857d704e3
commit 4651af5767
223 changed files with 1504 additions and 1752 deletions

View File

@@ -2040,7 +2040,7 @@ func (by *Bybit) DeleteSubUID(ctx context.Context, subMemberID string) error {
arg := &struct {
SubMemberID string `json:"subMemberId"`
}{SubMemberID: subMemberID}
var resp interface{}
var resp any
return by.SendAuthHTTPRequestV5(ctx, exchange.RestSpot, http.MethodPost, "/v5/user/del-submember", nil, arg, &resp, defaultEPL)
}
@@ -2545,7 +2545,7 @@ func processOB(ob [][2]string) ([]orderbook.Tranche, error) {
}
// SendHTTPRequest sends an unauthenticated request
func (by *Bybit) SendHTTPRequest(ctx context.Context, ePath exchange.URL, path string, f request.EndpointLimit, result interface{}) error {
func (by *Bybit) SendHTTPRequest(ctx context.Context, ePath exchange.URL, path string, f request.EndpointLimit, result any) error {
endpointPath, err := by.API.Endpoints.GetURL(ePath)
if err != nil {
return err
@@ -2577,7 +2577,7 @@ func (by *Bybit) SendHTTPRequest(ctx context.Context, ePath exchange.URL, path s
}
// SendAuthHTTPRequestV5 sends an authenticated HTTP request
func (by *Bybit) SendAuthHTTPRequestV5(ctx context.Context, ePath exchange.URL, method, path string, params url.Values, arg, result interface{}, f request.EndpointLimit) error {
func (by *Bybit) SendAuthHTTPRequestV5(ctx context.Context, ePath exchange.URL, method, path string, params url.Values, arg, result any, f request.EndpointLimit) error {
val := reflect.ValueOf(result)
if val.Kind() != reflect.Ptr {
return errNonePointerArgument

View File

@@ -12,7 +12,7 @@ func (a *orderbookResponse) UnmarshalJSON(data []byte) error {
}
err := json.Unmarshal(data, child)
if err != nil {
var resp []interface{}
var resp []any
err = json.Unmarshal(data, &resp)
if err != nil {
return err

View File

@@ -27,9 +27,9 @@ type orderbookResponse struct {
// Authenticate stores authentication variables required
type Authenticate struct {
RequestID string `json:"req_id"`
Args []interface{} `json:"args"`
Operation string `json:"op"`
RequestID string `json:"req_id"`
Args []any `json:"args"`
Operation string `json:"op"`
}
// SubscriptionArgument represents a subscription arguments.
@@ -105,9 +105,9 @@ type InstrumentInfo struct {
// RestResponse represents a REST response instance.
type RestResponse struct {
RetCode int64 `json:"retCode"`
RetMsg string `json:"retMsg"`
Result interface{} `json:"result"`
RetCode int64 `json:"retCode"`
RetMsg string `json:"retMsg"`
Result any `json:"result"`
RetExtInfo struct {
List []ErrorMessage `json:"list"`
} `json:"retExtInfo"`
@@ -344,7 +344,7 @@ type OrderResponse struct {
// AmendOrderParams represents a parameter for amending order.
type AmendOrderParams struct {
Category string `json:"category,omitempty"`
Symbol currency.Pair `json:"symbol,omitempty"`
Symbol currency.Pair `json:"symbol,omitzero"`
OrderID string `json:"orderId,omitempty"`
OrderLinkID string `json:"orderLinkId,omitempty"` // User customised order ID. A max of 36 characters. Combinations of numbers, letters (upper and lower cases), dashes, and underscores are supported. future orderLinkId rules:
OrderImpliedVolatility string `json:"orderIv,omitempty"`
@@ -373,7 +373,7 @@ type AmendOrderParams struct {
// CancelOrderParams represents a cancel order parameters.
type CancelOrderParams struct {
Category string `json:"category,omitempty"`
Symbol currency.Pair `json:"symbol,omitempty"`
Symbol currency.Pair `json:"symbol,omitzero"`
OrderID string `json:"orderId,omitempty"`
OrderLinkID string `json:"orderLinkId,omitempty"` // User customised order ID. A max of 36 characters. Combinations of numbers, letters (upper and lower cases), dashes, and underscores are supported. future orderLinkId rules:
@@ -464,7 +464,7 @@ type PlaceBatchOrderParam struct {
// BatchOrderItemParam represents a batch order place parameter.
type BatchOrderItemParam struct {
Category string `json:"category,omitempty"`
Symbol currency.Pair `json:"symbol,omitempty"`
Symbol currency.Pair `json:"symbol,omitzero"`
OrderType string `json:"orderType,omitempty"`
Side string `json:"side,omitempty"`
OrderQuantity float64 `json:"qty,string,omitempty"`
@@ -1242,7 +1242,7 @@ type WithdrawableAmount struct {
// WithdrawalParam represents asset withdrawal request parameter.
type WithdrawalParam struct {
Coin currency.Code `json:"coin,omitempty"`
Coin currency.Code `json:"coin,omitzero"`
Chain string `json:"chain,omitempty"`
Address string `json:"address,omitempty"`
Tag string `json:"tag,omitempty"`

View File

@@ -139,7 +139,7 @@ func (by *Bybit) WsAuth(ctx context.Context) error {
req := Authenticate{
RequestID: strconv.FormatInt(by.Websocket.AuthConn.GenerateMessageID(false), 10),
Operation: "auth",
Args: []interface{}{creds.Key, intNonce, sign},
Args: []any{creds.Key, intNonce, sign},
}
resp, err := by.Websocket.AuthConn.SendMessageReturnResponse(context.TODO(), request.Unset, req.RequestID, req)
if err != nil {