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:
Adrian Gallagher
2025-03-10 16:33:55 +11:00
committed by GitHub
parent c086e281cf
commit d64d56f77c
114 changed files with 5080 additions and 9355 deletions

View File

@@ -486,7 +486,7 @@ var filterOrdersByTypeBenchmark = &[]Detail{
// 392455 3226 ns/op 15840 B/op 5 allocs/op // PREV
// 9486490 109.5 ns/op 0 B/op 0 allocs/op // CURRENT
func BenchmarkFilterOrdersByType(b *testing.B) {
for x := 0; x < b.N; x++ {
for b.Loop() {
FilterOrdersByType(filterOrdersByTypeBenchmark, Limit)
}
}
@@ -538,7 +538,7 @@ var filterOrdersBySideBenchmark = &[]Detail{
// 372594 3049 ns/op 15840 B/op 5 allocs/op // PREV
// 7412187 148.8 ns/op 0 B/op 0 allocs/op // CURRENT
func BenchmarkFilterOrdersBySide(b *testing.B) {
for x := 0; x < b.N; x++ {
for b.Loop() {
FilterOrdersBySide(filterOrdersBySideBenchmark, Ask)
}
}
@@ -623,7 +623,7 @@ var filterOrdersByTimeRangeBenchmark = &[]Detail{
// 390822 3335 ns/op 15840 B/op 5 allocs/op // PREV
// 6201034 172.1 ns/op 0 B/op 0 allocs/op // CURRENT
func BenchmarkFilterOrdersByTimeRange(b *testing.B) {
for x := 0; x < b.N; x++ {
for b.Loop() {
err := FilterOrdersByTimeRange(filterOrdersByTimeRangeBenchmark, time.Unix(50, 0), time.Unix(150, 0))
if err != nil {
b.Fatal(err)
@@ -705,7 +705,7 @@ var filterOrdersByPairsBenchmark = &[]Detail{
// 6977242 172.8 ns/op 0 B/op 0 allocs/op // CURRENT
func BenchmarkFilterOrdersByPairs(b *testing.B) {
pairs := []currency.Pair{currency.NewPair(currency.BTC, currency.USD)}
for x := 0; x < b.N; x++ {
for b.Loop() {
FilterOrdersByPairs(filterOrdersByPairsBenchmark, pairs)
}
}
@@ -908,7 +908,7 @@ var sideBenchmark Side
// 9756914 126.7 ns/op 0 B/op 0 allocs/op // PREV
// 25200660 57.63 ns/op 3 B/op 1 allocs/op // CURRENT
func BenchmarkStringToOrderSide(b *testing.B) {
for x := 0; x < b.N; x++ {
for b.Loop() {
sideBenchmark, _ = StringToOrderSide("any")
}
}
@@ -986,7 +986,7 @@ var typeBenchmark Type
// 5703705 299.9 ns/op 0 B/op 0 allocs/op // PREV
// 16353608 81.23 ns/op 8 B/op 1 allocs/op // CURRENT
func BenchmarkStringToOrderType(b *testing.B) {
for x := 0; x < b.N; x++ {
for b.Loop() {
typeBenchmark, _ = StringToOrderType("trigger")
}
}
@@ -1063,7 +1063,7 @@ var statusBenchmark Status
// 3569052 351.8 ns/op 0 B/op 0 allocs/op // PREV
// 11126791 101.9 ns/op 24 B/op 1 allocs/op // CURRENT
func BenchmarkStringToOrderStatus(b *testing.B) {
for x := 0; x < b.N; x++ {
for b.Loop() {
statusBenchmark, _ = StringToOrderStatus("market_unavailable")
}
}
@@ -1662,7 +1662,7 @@ var activeBenchmark = Detail{Status: Pending, Amount: 1}
// 610732089 2.414 ns/op 0 B/op 0 allocs/op // PREV
// 1000000000 1.188 ns/op 0 B/op 0 allocs/op // CURRENT
func BenchmarkIsActive(b *testing.B) {
for x := 0; x < b.N; x++ {
for b.Loop() {
if !activeBenchmark.IsActive() {
b.Fatal("expected true")
}
@@ -1730,7 +1730,7 @@ var inactiveBenchmark = Detail{Status: Closed, Amount: 1}
// 1000000000 1.043 ns/op 0 B/op 0 allocs/op // CURRENT
func BenchmarkIsInactive(b *testing.B) {
for x := 0; x < b.N; x++ {
for b.Loop() {
if !inactiveBenchmark.IsInactive() {
b.Fatal("expected true")
}
@@ -1875,9 +1875,8 @@ func TestDetail_CopyPointerOrderSlice(t *testing.T) {
func TestDeriveModify(t *testing.T) {
t.Parallel()
var o *Detail
if _, err := o.DeriveModify(); !errors.Is(err, errOrderDetailIsNil) {
t.Fatalf("received: '%v' but expected: '%v'", err, errOrderDetailIsNil)
}
_, err := o.DeriveModify()
require.ErrorIs(t, err, errOrderDetailIsNil)
pair := currency.NewPair(currency.BTC, currency.AUD)
@@ -1892,31 +1891,26 @@ func TestDeriveModify(t *testing.T) {
}
mod, err := o.DeriveModify()
if !errors.Is(err, nil) {
t.Fatalf("received: '%v' but expected: '%v'", err, nil)
}
require.NoError(t, err)
require.NotNil(t, mod)
if mod == nil {
t.Fatal("should not be nil")
}
if mod.Exchange != "wow" ||
mod.OrderID != "wow2" ||
mod.ClientOrderID != "wow3" ||
mod.Type != Market ||
mod.Side != Long ||
mod.AssetType != asset.Futures ||
!mod.Pair.Equal(pair) {
t.Fatal("unexpected values")
exp := &Modify{
Exchange: "wow",
OrderID: "wow2",
ClientOrderID: "wow3",
Type: Market,
Side: Long,
AssetType: asset.Futures,
Pair: pair,
}
assert.Equal(t, exp, mod)
}
func TestDeriveModifyResponse(t *testing.T) {
t.Parallel()
var mod *Modify
if _, err := mod.DeriveModifyResponse(); !errors.Is(err, errOrderDetailIsNil) {
t.Fatalf("received: '%v' but expected: '%v'", err, errOrderDetailIsNil)
}
_, err := mod.DeriveModifyResponse()
require.ErrorIs(t, err, errOrderDetailIsNil)
pair := currency.NewPair(currency.BTC, currency.AUD)
@@ -1931,23 +1925,19 @@ func TestDeriveModifyResponse(t *testing.T) {
}
modresp, err := mod.DeriveModifyResponse()
if !errors.Is(err, nil) {
t.Fatalf("received: '%v' but expected: '%v'", err, nil)
}
require.NoError(t, err, "DeriveModifyResponse must not error")
require.NotNil(t, modresp)
if modresp == nil {
t.Fatal("should not be nil")
}
if modresp.Exchange != "wow" ||
modresp.OrderID != "wow2" ||
modresp.ClientOrderID != "wow3" ||
modresp.Type != Market ||
modresp.Side != Long ||
modresp.AssetType != asset.Futures ||
!modresp.Pair.Equal(pair) {
t.Fatal("unexpected values")
exp := &ModifyResponse{
Exchange: "wow",
OrderID: "wow2",
ClientOrderID: "wow3",
Type: Market,
Side: Long,
AssetType: asset.Futures,
Pair: pair,
}
assert.Equal(t, exp, modresp)
}
func TestDeriveCancel(t *testing.T) {