golangci-lint/CI: Bump versions and introduce new linters (#798)

* golangci-lint/CI: Bump versions

Fix remaining linter issues

* Specifically set AppVeyor version

* Fix the infamous typos 👀

* Add go env cmd to AppVeyor

* Add go version cmd to AppVeyor

* Specify AppVeyor image, adjust linters

* Update go get to go install due to deprecation

* Bump golangci-lint timeout time for AppVeyor

* Change NW contract to NQ

* Address nitters

* GetRandomPair -> Pair{}

* Address nits

* Address time nitterinos plus additional tweaks

* More time inception upgrades!

* Bending time and space
This commit is contained in:
Adrian Gallagher
2021-10-14 16:38:53 +11:00
committed by GitHub
parent 0a91af0f2e
commit f0d45aa1d2
194 changed files with 1506 additions and 1233 deletions

View File

@@ -236,7 +236,11 @@ func (b *Bithumb) GetAccountBalance(ctx context.Context, c string) (FullBalance,
return fullBalance, err
}
} else {
val = datum.(float64)
var ok bool
val, ok = datum.(float64)
if !ok {
return fullBalance, errors.New("unable to type assert datum")
}
}
switch splitTag[0] {
@@ -529,7 +533,7 @@ func (b *Bithumb) SendAuthenticatedHTTPRequest(ctx context.Context, ep exchange.
var intermediary json.RawMessage
err = b.SendPayload(ctx, request.Auth, func() (*request.Item, error) {
// This is time window sensitive
tnMS := time.Now().UnixNano() / int64(time.Millisecond)
tnMS := time.Now().UnixMilli()
n := strconv.FormatInt(tnMS, 10)
params.Set("endpoint", path)

View File

@@ -291,8 +291,7 @@ func (b *Bithumb) UpdateTickers(ctx context.Context, a asset.Item) error {
// UpdateTicker updates and returns the ticker for a currency pair
func (b *Bithumb) UpdateTicker(ctx context.Context, p currency.Pair, a asset.Item) (*ticker.Price, error) {
err := b.UpdateTickers(ctx, a)
if err != nil {
if err := b.UpdateTickers(ctx, a); err != nil {
return nil, err
}
return ticker.GetTicker(b.Name, p, a)
@@ -818,60 +817,33 @@ func (b *Bithumb) GetHistoricCandles(ctx context.Context, pair currency.Pair, a
}
for x := range candle.Data {
if len(candle.Data[x]) < 6 {
return kline.Item{}, errors.New("invalid candle length")
}
var tempCandle kline.Candle
tempTime := candle.Data[x][0].(float64)
timestamp := time.Unix(0, int64(tempTime)*int64(time.Millisecond))
if timestamp.Before(start) {
if tempCandle.Time, err = convert.TimeFromUnixTimestampFloat(candle.Data[x][0]); err != nil {
return kline.Item{}, fmt.Errorf("unable to convert timestamp: %w", err)
}
if tempCandle.Time.Before(start) {
continue
}
if timestamp.After(end) {
if tempCandle.Time.After(end) {
break
}
tempCandle.Time = timestamp
open, ok := candle.Data[x][1].(string)
if !ok {
return kline.Item{}, errors.New("open conversion failed")
if tempCandle.Open, err = convert.FloatFromString(candle.Data[x][1]); err != nil {
return kline.Item{}, fmt.Errorf("kline open conversion failed: %w", err)
}
tempCandle.Open, err = strconv.ParseFloat(open, 64)
if err != nil {
return kline.Item{}, err
if tempCandle.High, err = convert.FloatFromString(candle.Data[x][2]); err != nil {
return kline.Item{}, fmt.Errorf("kline high conversion failed: %w", err)
}
high, ok := candle.Data[x][2].(string)
if !ok {
return kline.Item{}, errors.New("high conversion failed")
if tempCandle.Low, err = convert.FloatFromString(candle.Data[x][3]); err != nil {
return kline.Item{}, fmt.Errorf("kline low conversion failed: %w", err)
}
tempCandle.High, err = strconv.ParseFloat(high, 64)
if err != nil {
return kline.Item{}, err
if tempCandle.Close, err = convert.FloatFromString(candle.Data[x][4]); err != nil {
return kline.Item{}, fmt.Errorf("kline close conversion failed: %w", err)
}
low, ok := candle.Data[x][3].(string)
if !ok {
return kline.Item{}, errors.New("low conversion failed")
}
tempCandle.Low, err = strconv.ParseFloat(low, 64)
if err != nil {
return kline.Item{}, err
}
closeTemp, ok := candle.Data[x][4].(string)
if !ok {
return kline.Item{}, errors.New("close conversion failed")
}
tempCandle.Close, err = strconv.ParseFloat(closeTemp, 64)
if err != nil {
return kline.Item{}, err
}
vol, ok := candle.Data[x][5].(string)
if !ok {
return kline.Item{}, errors.New("vol conversion failed")
}
tempCandle.Volume, err = strconv.ParseFloat(vol, 64)
if err != nil {
return kline.Item{}, err
if tempCandle.Volume, err = convert.FloatFromString(candle.Data[x][5]); err != nil {
return kline.Item{}, fmt.Errorf("kline volume conversion failed: %w", err)
}
ret.Candles = append(ret.Candles, tempCandle)
}

View File

@@ -442,7 +442,7 @@ func (b *Bithumb) SeedLocalCacheWithBook(p currency.Pair, o *Orderbook) error {
newOrderBook.Pair = p
newOrderBook.Asset = asset.Spot
newOrderBook.Exchange = b.Name
newOrderBook.LastUpdated = time.Unix(0, o.Data.Timestamp*int64(time.Millisecond))
newOrderBook.LastUpdated = time.UnixMilli(o.Data.Timestamp)
newOrderBook.VerifyOrderbook = b.CanVerifyOrderbook
return b.Websocket.Orderbook.LoadSnapshot(&newOrderBook)
}

View File

@@ -20,7 +20,7 @@ func TestBithumbTime(t *testing.T) {
tt := newTime.Time()
if tt.UTC().String() != "2021-08-12 03:39:50 +0000 UTC" {
t.Fatalf("expected: %s but receieved: %s",
t.Fatalf("expected: %s but received: %s",
"2021-08-12 03:39:50 +0000 UTC",
tt.UTC().String())
}