CI/build: Update Go version, linters and fix minor issues (#1473)

* CI/build: Update Go version, linters and fix minor issues

* Bump golangci-lint to v1.56.1

* BinanceUS: Make uint usage consistent

* Throw blank identifiers into the trash
This commit is contained in:
Adrian Gallagher
2024-02-14 11:02:06 +11:00
committed by GitHub
parent 9ff502bac2
commit 08da42ddb7
79 changed files with 364 additions and 374 deletions

View File

@@ -18,12 +18,13 @@ var (
ErrNoTickerFound = errors.New("no ticker found")
// ErrBidEqualsAsk error for locked markets
ErrBidEqualsAsk = errors.New("bid equals ask this is a crossed or locked market")
// ErrExchangeNameIsEmpty is an error for when an exchange name is empty
ErrExchangeNameIsEmpty = errors.New("exchange name is empty")
errInvalidTicker = errors.New("invalid ticker")
errTickerNotFound = errors.New("ticker not found")
errExchangeNameIsEmpty = errors.New("exchange name is empty")
errBidGreaterThanAsk = errors.New("bid greater than ask this is a crossed or locked market")
errExchangeNotFound = errors.New("exchange not found")
errInvalidTicker = errors.New("invalid ticker")
errTickerNotFound = errors.New("ticker not found")
errBidGreaterThanAsk = errors.New("bid greater than ask this is a crossed or locked market")
errExchangeNotFound = errors.New("exchange not found")
)
func init() {
@@ -71,7 +72,7 @@ func SubscribeToExchangeTickers(exchange string) (dispatch.Pipe, error) {
// GetTicker checks and returns a requested ticker if it exists
func GetTicker(exchange string, p currency.Pair, a asset.Item) (*Price, error) {
if exchange == "" {
return nil, errExchangeNameIsEmpty
return nil, ErrExchangeNameIsEmpty
}
if p.IsEmpty() {
return nil, currency.ErrCurrencyPairEmpty
@@ -104,7 +105,7 @@ func GetExchangeTickers(exchange string) ([]*Price, error) {
func (s *Service) getExchangeTickers(exchange string) ([]*Price, error) {
if exchange == "" {
return nil, errExchangeNameIsEmpty
return nil, ErrExchangeNameIsEmpty
}
exchange = strings.ToLower(exchange)
s.mu.Lock()
@@ -148,7 +149,7 @@ func ProcessTicker(p *Price) error {
}
if p.ExchangeName == "" {
return fmt.Errorf(ErrExchangeNameUnset)
return ErrExchangeNameIsEmpty
}
if p.Pair.IsEmpty() {
@@ -240,7 +241,7 @@ func (s *Service) setItemID(t *Ticker, p *Price, exch string) error {
// getAssociations links a singular book with its dispatch associations
func (s *Service) getAssociations(exch string) ([]uuid.UUID, error) {
if exch == "" {
return nil, errExchangeNameIsEmpty
return nil, ErrExchangeNameIsEmpty
}
var ids []uuid.UUID
exchangeID, ok := s.Exchange[exch]

View File

@@ -437,9 +437,7 @@ func TestProcessTicker(t *testing.T) { // non-appending function to tickers
func TestGetAssociation(t *testing.T) {
_, err := service.getAssociations("")
if !errors.Is(err, errExchangeNameIsEmpty) {
t.Errorf("received: %v but expected: %v", err, errExchangeNameIsEmpty)
}
assert.ErrorIs(t, err, ErrExchangeNameIsEmpty)
service.mux = nil
@@ -453,7 +451,7 @@ func TestGetAssociation(t *testing.T) {
func TestGetExchangeTickersPublic(t *testing.T) {
_, err := GetExchangeTickers("")
assert.ErrorIs(t, err, errExchangeNameIsEmpty)
assert.ErrorIs(t, err, ErrExchangeNameIsEmpty)
}
func TestGetExchangeTickers(t *testing.T) {
@@ -464,7 +462,7 @@ func TestGetExchangeTickers(t *testing.T) {
}
_, err := s.getExchangeTickers("")
assert.ErrorIs(t, err, errExchangeNameIsEmpty)
assert.ErrorIs(t, err, ErrExchangeNameIsEmpty)
_, err = s.getExchangeTickers("test")
assert.ErrorIs(t, err, errExchangeNotFound)
@@ -489,5 +487,5 @@ func TestGetExchangeTickers(t *testing.T) {
if len(resp) != 1 {
t.Fatal("unexpected length")
}
assert.Equal(t, resp[0].OpenInterest, 1337.0)
assert.Equal(t, 1337.0, resp[0].OpenInterest)
}

View File

@@ -13,10 +13,9 @@ import (
// const values for the ticker package
const (
ErrExchangeNameUnset = "ticker exchange name not set"
errPairNotSet = "ticker currency pair not set"
errAssetTypeNotSet = "ticker asset type not set"
errTickerPriceIsNil = "ticker price is nil"
errPairNotSet = "ticker currency pair not set"
errAssetTypeNotSet = "ticker asset type not set"
errTickerPriceIsNil = "ticker price is nil"
)
// Vars for the ticker package