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

@@ -419,7 +419,7 @@ func (h *HitBTC) GetFeeInfo(ctx context.Context, currencyPair string) (Fee, erro
}
// SendHTTPRequest sends an unauthenticated HTTP request
func (h *HitBTC) SendHTTPRequest(ctx context.Context, ep exchange.URL, path string, result interface{}) error {
func (h *HitBTC) SendHTTPRequest(ctx context.Context, ep exchange.URL, path string, result any) error {
endpoint, err := h.API.Endpoints.GetURL(ep)
if err != nil {
return err
@@ -440,7 +440,7 @@ func (h *HitBTC) SendHTTPRequest(ctx context.Context, ep exchange.URL, path stri
}
// SendAuthenticatedHTTPRequest sends an authenticated http request
func (h *HitBTC) SendAuthenticatedHTTPRequest(ctx context.Context, ep exchange.URL, method, endpoint string, values url.Values, f request.EndpointLimit, result interface{}) error {
func (h *HitBTC) SendAuthenticatedHTTPRequest(ctx context.Context, ep exchange.URL, method, endpoint string, values url.Values, f request.EndpointLimit, result any) error {
creds, err := h.GetCredentials(ctx)
if err != nil {
return err

View File

@@ -280,8 +280,8 @@ type LendingHistory struct {
type capture struct {
Method string `json:"method,omitempty"`
Result interface{} `json:"result"`
Error ResponseError `json:"error,omitempty"`
Result any `json:"result"`
Error ResponseError `json:"error"`
ID int64 `json:"id,omitempty"`
}
@@ -372,7 +372,7 @@ type WsLoginData struct {
// wsActiveOrdersResponse Active order response for auth subscription to reports
type wsActiveOrdersResponse struct {
Params []wsOrderData `json:"params"`
Error ResponseError `json:"error,omitempty"`
Error ResponseError `json:"error"`
}
type wsReportResponse struct {
@@ -416,7 +416,7 @@ type wsOrderData struct {
// WsReportResponse report response for auth subscription to reports
type WsReportResponse struct {
Params WsReportResponseData `json:"params"`
Error ResponseError `json:"error,omitempty"`
Error ResponseError `json:"error"`
}
// WsReportResponseData Report data for WsReportResponse
@@ -461,7 +461,7 @@ type WsSubmitOrderRequestData struct {
type WsSubmitOrderSuccessResponse struct {
Result WsSubmitOrderSuccessResponseData `json:"result"`
ID int64 `json:"id"`
Error ResponseError `json:"error,omitempty"`
Error ResponseError `json:"error"`
}
// WsSubmitOrderSuccessResponseData WS response data
@@ -484,7 +484,7 @@ type WsSubmitOrderSuccessResponseData struct {
// WsSubmitOrderErrorResponse WS error response
type WsSubmitOrderErrorResponse struct {
Error WsSubmitOrderErrorResponseData `json:"error,omitempty"`
Error WsSubmitOrderErrorResponseData `json:"error"`
ID int64 `json:"id"`
}
@@ -499,7 +499,7 @@ type WsSubmitOrderErrorResponseData struct {
type WsCancelOrderResponse struct {
Result WsCancelOrderResponseData `json:"result"`
ID int64 `json:"id"`
Error ResponseError `json:"error,omitempty"`
Error ResponseError `json:"error"`
}
// WsCancelOrderResponseData WS response data
@@ -524,7 +524,7 @@ type WsCancelOrderResponseData struct {
type WsReplaceOrderResponse struct {
Result WsReplaceOrderResponseData `json:"result"`
ID int64 `json:"id"`
Error ResponseError `json:"error,omitempty"`
Error ResponseError `json:"error"`
}
// WsReplaceOrderResponseData WS response data
@@ -550,7 +550,7 @@ type WsReplaceOrderResponseData struct {
type WsGetActiveOrdersResponse struct {
Result []WsGetActiveOrdersResponseData `json:"result"`
ID int64 `json:"id"`
Error ResponseError `json:"error,omitempty"`
Error ResponseError `json:"error"`
}
// WsGetActiveOrdersResponseData WS response data
@@ -576,7 +576,7 @@ type WsGetActiveOrdersResponseData struct {
type WsGetTradingBalanceResponse struct {
Result []WsGetTradingBalanceResponseData `json:"result"`
ID int64 `json:"id"`
Error ResponseError `json:"error,omitempty"`
Error ResponseError `json:"error"`
}
// WsGetTradingBalanceResponseData WS response data
@@ -629,7 +629,7 @@ type WsGetCurrenciesRequestParameters struct {
type WsGetCurrenciesResponse struct {
Result WsGetCurrenciesResponseData `json:"result"`
ID int64 `json:"id"`
Error ResponseError `json:"error,omitempty"`
Error ResponseError `json:"error"`
}
// WsGetCurrenciesResponseData currency response data
@@ -663,7 +663,7 @@ type WsGetSymbolsRequestParameters struct {
type WsGetSymbolsResponse struct {
Result WsGetSymbolsResponseData `json:"result"`
ID int64 `json:"id"`
Error ResponseError `json:"error,omitempty"`
Error ResponseError `json:"error"`
}
// WsGetSymbolsResponseData symbol response data
@@ -698,7 +698,7 @@ type WsGetTradesResponse struct {
Jsonrpc string `json:"jsonrpc"`
Result WsGetTradesResponseData `json:"result"`
ID int64 `json:"id"`
Error ResponseError `json:"error,omitempty"`
Error ResponseError `json:"error"`
}
// WsGetTradesResponseData trade response data

View File

@@ -117,7 +117,7 @@ func (h *HitBTC) wsGetTableName(respRaw []byte) (string, error) {
return init.Method, nil
}
switch resultType := init.Result.(type) {
case map[string]interface{}:
case map[string]any:
if reportType, ok := resultType["reportType"].(string); ok {
return reportType, nil
}
@@ -128,13 +128,13 @@ func (h *HitBTC) wsGetTableName(respRaw []byte) (string, error) {
return "", nil
}
}
case []interface{}:
case []any:
if len(resultType) == 0 {
h.Websocket.DataHandler <- fmt.Sprintf("No data returned. ID: %v", init.ID)
return "", nil
}
data, ok := resultType[0].(map[string]interface{})
data, ok := resultType[0].(map[string]any)
if !ok {
return "", errors.New("unable to type assert data")
}