mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-04 15:10:54 +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:
@@ -320,33 +320,43 @@ func (k *Kraken) GetTrades(ctx context.Context, symbol currency.Pair) ([]RecentT
|
||||
return nil, errors.New("unrecognised trade data received")
|
||||
}
|
||||
var r RecentTrades
|
||||
r.Price, err = strconv.ParseFloat(individualTrade[0].(string), 64)
|
||||
|
||||
price, ok := individualTrade[0].(string)
|
||||
if !ok {
|
||||
return nil, common.GetTypeAssertError("string", individualTrade[0], "price")
|
||||
}
|
||||
r.Price, err = strconv.ParseFloat(price, 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r.Volume, err = strconv.ParseFloat(individualTrade[1].(string), 64)
|
||||
|
||||
volume, ok := individualTrade[1].(string)
|
||||
if !ok {
|
||||
return nil, common.GetTypeAssertError("string", individualTrade[1], "volume")
|
||||
}
|
||||
r.Volume, err = strconv.ParseFloat(volume, 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r.Time, ok = individualTrade[2].(float64)
|
||||
if !ok {
|
||||
return nil, errors.New("unable to parse time for individual trade data")
|
||||
return nil, common.GetTypeAssertError("float64", individualTrade[2], "time")
|
||||
}
|
||||
r.BuyOrSell, ok = individualTrade[3].(string)
|
||||
if !ok {
|
||||
return nil, errors.New("unable to parse order side for individual trade data")
|
||||
return nil, common.GetTypeAssertError("string", individualTrade[3], "buyOrSell")
|
||||
}
|
||||
r.MarketOrLimit, ok = individualTrade[4].(string)
|
||||
if !ok {
|
||||
return nil, errors.New("unable to parse order type for individual trade data")
|
||||
return nil, common.GetTypeAssertError("string", individualTrade[4], "marketOrLimit")
|
||||
}
|
||||
r.Miscellaneous, ok = individualTrade[5].(string)
|
||||
if !ok {
|
||||
return nil, errors.New("unable to parse misc field for individual trade data")
|
||||
return nil, common.GetTypeAssertError("string", individualTrade[5], "miscellaneous")
|
||||
}
|
||||
tradeID, ok := individualTrade[6].(float64)
|
||||
if !ok {
|
||||
return nil, errors.New("unable to parse TradeID field for individual trade data")
|
||||
return nil, common.GetTypeAssertError("float64", individualTrade[6], "tradeID")
|
||||
}
|
||||
r.TradeID = int64(tradeID)
|
||||
recentTrades[x] = r
|
||||
|
||||
@@ -491,23 +491,27 @@ func (k *Kraken) wsProcessSpread(response []any, pair currency.Pair) error {
|
||||
}
|
||||
bestBid, ok := data[0].(string)
|
||||
if !ok {
|
||||
return errors.New("wsProcessSpread: unable to type assert bestBid")
|
||||
return common.GetTypeAssertError("string", data[0], "bestBid")
|
||||
}
|
||||
bestAsk, ok := data[1].(string)
|
||||
if !ok {
|
||||
return errors.New("wsProcessSpread: unable to type assert bestAsk")
|
||||
return common.GetTypeAssertError("string", data[1], "bestAsk")
|
||||
}
|
||||
timeData, err := strconv.ParseFloat(data[2].(string), 64)
|
||||
timeData, ok := data[2].(string)
|
||||
if !ok {
|
||||
return common.GetTypeAssertError("string", data[2], "timeData")
|
||||
}
|
||||
timestamp, err := strconv.ParseFloat(timeData, 64)
|
||||
if err != nil {
|
||||
return fmt.Errorf("wsProcessSpread: unable to parse timeData: %w", err)
|
||||
return err
|
||||
}
|
||||
bidVolume, ok := data[3].(string)
|
||||
if !ok {
|
||||
return errors.New("wsProcessSpread: unable to type assert bidVolume")
|
||||
return common.GetTypeAssertError("string", data[3], "bidVolume")
|
||||
}
|
||||
askVolume, ok := data[4].(string)
|
||||
if !ok {
|
||||
return errors.New("wsProcessSpread: unable to type assert askVolume")
|
||||
return common.GetTypeAssertError("string", data[4], "askVolume")
|
||||
}
|
||||
|
||||
if k.Verbose {
|
||||
@@ -517,7 +521,7 @@ func (k *Kraken) wsProcessSpread(response []any, pair currency.Pair) error {
|
||||
pair,
|
||||
bestBid,
|
||||
bestAsk,
|
||||
convert.TimeFromUnixTimestampDecimal(timeData),
|
||||
convert.TimeFromUnixTimestampDecimal(timestamp),
|
||||
bidVolume,
|
||||
askVolume)
|
||||
}
|
||||
@@ -901,7 +905,7 @@ func (k *Kraken) wsProcessOrderBookUpdate(pair currency.Pair, askData, bidData [
|
||||
return fmt.Errorf("cannot calculate websocket checksum: book not found for %s %s %w", pair, asset.Spot, err)
|
||||
}
|
||||
|
||||
token, err := strconv.ParseInt(checksum, 10, 64)
|
||||
token, err := strconv.ParseUint(checksum, 10, 32)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user