CI: Fix golangci-lint linter issues, add prealloc linter and bump version depends for Go 1.18 (#915)

* Bump CI versions

* Specifically set go version as 1.17.x bumps it to 1.18

* Another

* Adjust AppVeyor

* Part 1 of linter issues

* Part 2

* Fix various linters and improvements

* Part 3

* Finishing touches

* Tests and EqualFold

* Fix nitterinos plus bonus requester jobs bump for exchanges with large number of tests

* Fix nitterinos and bump golangci-lint timeout for AppVeyor

* Address nits, ensure all books are returned on err due to syncer regression

* Fix the wiggins

* Fix duplication

* Fix nitterinos
This commit is contained in:
Adrian Gallagher
2022-04-20 13:45:15 +10:00
committed by GitHub
parent c48e5ea90a
commit 9a4eb9de84
216 changed files with 3493 additions and 2424 deletions

View File

@@ -17,8 +17,8 @@ func NewMatch() *Match {
// connections. Stream systems fan in all incoming payloads to one routine for
// processing.
type Match struct {
m map[interface{}]chan []byte
sync.Mutex
m map[interface{}]chan []byte
mu sync.Mutex
}
// Incoming matches with request, disregarding the returned payload
@@ -29,8 +29,8 @@ func (m *Match) Incoming(signature interface{}) bool {
// IncomingWithData matches with requests and takes in the returned payload, to
// be processed outside of a stream processing routine
func (m *Match) IncomingWithData(signature interface{}, data []byte) bool {
m.Lock()
defer m.Unlock()
m.mu.Lock()
defer m.mu.Unlock()
ch, ok := m.m[signature]
if ok {
select {
@@ -47,15 +47,15 @@ func (m *Match) IncomingWithData(signature interface{}, data []byte) bool {
// Sets the signature response channel for incoming data
func (m *Match) set(signature interface{}) (matcher, error) {
var ch chan []byte
m.Lock()
m.mu.Lock()
if _, ok := m.m[signature]; ok {
m.Unlock()
m.mu.Unlock()
return matcher{}, errors.New("signature collision")
}
// This is buffered so we don't need to wait for receiver.
ch = make(chan []byte, 1)
m.m[signature] = ch
m.Unlock()
m.mu.Unlock()
return matcher{
C: ch,
@@ -73,8 +73,8 @@ type matcher struct {
// Cleanup closes underlying channel and deletes signature from map
func (m *matcher) Cleanup() {
m.m.Lock()
m.m.mu.Lock()
close(m.C)
delete(m.m.m, m.sig)
m.m.Unlock()
m.m.mu.Unlock()
}

View File

@@ -6,7 +6,7 @@ import (
"compress/gzip"
"crypto/rand"
"fmt"
"io/ioutil"
"io"
"math/big"
"net"
"net/http"
@@ -156,7 +156,7 @@ func (w *WebsocketConnection) SetupPingHandler(handler PingHandler) {
time.Now().Add(handler.Delay))
if err == websocket.ErrCloseSent {
return nil
} else if e, ok := err.(net.Error); ok && e.Temporary() {
} else if e, ok := err.(net.Error); ok && e.Timeout() {
return nil
}
return err
@@ -260,7 +260,7 @@ func (w *WebsocketConnection) parseBinaryResponse(resp []byte) ([]byte, error) {
if err != nil {
return standardMessage, err
}
standardMessage, err = ioutil.ReadAll(gReader)
standardMessage, err = io.ReadAll(gReader)
if err != nil {
return standardMessage, err
}
@@ -270,7 +270,7 @@ func (w *WebsocketConnection) parseBinaryResponse(resp []byte) ([]byte, error) {
}
} else {
reader := flate.NewReader(bytes.NewReader(resp))
standardMessage, err = ioutil.ReadAll(reader)
standardMessage, err = io.ReadAll(reader)
if err != nil {
return standardMessage, err
}

View File

@@ -305,7 +305,10 @@ func TestConnectionMessageErrors(t *testing.T) {
ws.ReadMessageErrors <- errors.New("errorText")
select {
case err := <-ws.ToRoutine:
if err.(error).Error() != "errorText" {
errText, ok := err.(error)
if !ok {
t.Error("unable to type assert error")
} else if errText.Error() != "errorText" {
t.Errorf("Expected 'errorText', received %v", err)
}
case <-timer.C:
@@ -1045,12 +1048,12 @@ type GenSubs struct {
// generateSubs default subs created from the enabled pairs list
func (g *GenSubs) generateSubs() ([]ChannelSubscription, error) {
var superduperchannelsubs []ChannelSubscription
superduperchannelsubs := make([]ChannelSubscription, len(g.EnabledPairs))
for i := range g.EnabledPairs {
superduperchannelsubs = append(superduperchannelsubs, ChannelSubscription{
superduperchannelsubs[i] = ChannelSubscription{
Channel: "TEST:" + strconv.FormatInt(int64(i), 10),
Currency: g.EnabledPairs[i],
})
}
}
return superduperchannelsubs, nil
}