Skip to content

Commit

Permalink
fixup! GateIO: Improve WS Header parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
gbjk committed Jan 13, 2025
1 parent 2cfa3e7 commit 3028129
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions exchanges/gateio/gateio_websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,17 +223,18 @@ func parseWSHeader(msg []byte) (r *WSResponse, errs error) {
jsonparser.EachKey(msg, func(idx int, v []byte, _ jsonparser.ValueType, _ error) {
switch idx {
case 0: // time_ms
if ts, err := strconv.Atoi(string(v)); err != nil {
if ts, err := strconv.ParseInt(string(v), 10, 64); err != nil {
errs = common.AppendError(errs, fmt.Errorf("%w parsing `time_ms`", err))
} else {
r.Time = time.UnixMilli(int64(ts))
r.Time = time.UnixMilli(ts)
}
case 1: // time
if r.Time.IsZero() {

Check failure on line 232 in exchanges/gateio/gateio_websocket.go

View workflow job for this annotation

GitHub Actions / lint

unnecessary leading newline (whitespace)
if ts, err := strconv.Atoi(string(v)); err != nil {

if ts, err := strconv.ParseInt(string(v), 10, 64); err != nil {
errs = common.AppendError(errs, fmt.Errorf("%w parsing `time`", err))
} else {
r.Time = time.Unix(int64(ts), 0)
r.Time = time.Unix(ts, 0)
}
}
case 2:
Expand All @@ -243,10 +244,10 @@ func parseWSHeader(msg []byte) (r *WSResponse, errs error) {
case 4:
r.RequestID = string(v)
case 5:
if id, err := strconv.Atoi(string(v)); err != nil {
if id, err := strconv.ParseInt(string(v), 10, 64); err != nil {
errs = common.AppendError(errs, fmt.Errorf("%w parsing `id`", err))
} else {
r.ID = int64(id)
r.ID = id
}
case 6:
r.Result = json.RawMessage(v)
Expand Down

0 comments on commit 3028129

Please sign in to comment.