From 4a7c296695cb7a24c6ddd301ef6cad49812abc2c Mon Sep 17 00:00:00 2001 From: ccoVeille <3875889+ccoVeille@users.noreply.github.com> Date: Tue, 2 Dec 2025 13:23:34 +0100 Subject: [PATCH 1/3] chore: make sure to run the CI on latest Go versions Also, add Go 1.18 to the list of Go versions to test against since it's still supported by go-redis. --- .github/actions/run-tests/action.yml | 2 +- .github/workflows/build.yml | 9 +++++---- .github/workflows/doctests.yaml | 2 +- .github/workflows/test-redis-enterprise.yml | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/actions/run-tests/action.yml b/.github/actions/run-tests/action.yml index 0ee098673..058b3e6fc 100644 --- a/.github/actions/run-tests/action.yml +++ b/.github/actions/run-tests/action.yml @@ -3,7 +3,7 @@ description: 'Runs go-redis tests against different Redis versions and configura inputs: go-version: description: 'Go version to use for running tests' - default: '1.23' + default: 'stable' redis-version: description: 'Redis version to test against' required: true diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b3fc81361..df686ad9a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,8 +22,8 @@ jobs: - "8.2.x" # Redis CE 8.2 - "8.0.x" # Redis CE 8.0 go-version: - - "1.23.x" - - "1.24.x" + - "stable" # The latest stable Go release + - "oldstable" # The previous Go release before stable steps: - name: Set up ${{ matrix.go-version }} @@ -78,8 +78,9 @@ jobs: - "8.2.x" # Redis CE 8.2 - "8.0.x" # Redis CE 8.0 go-version: - - "1.23.x" - - "1.24.x" + - "stable" # The latest stable Go release + - "oldstable" # The previous Go release before stable + - "1.18.x" # Go 1.18 is the minimum supported version for go-redis (see go.mod) steps: - name: Checkout code diff --git a/.github/workflows/doctests.yaml b/.github/workflows/doctests.yaml index 55d022edc..58e4b5d4e 100644 --- a/.github/workflows/doctests.yaml +++ b/.github/workflows/doctests.yaml @@ -27,7 +27,7 @@ jobs: strategy: fail-fast: false matrix: - go-version: ["1.24"] + go-version: ["stable", "1.18"] steps: - name: Set up ${{ matrix.go-version }} diff --git a/.github/workflows/test-redis-enterprise.yml b/.github/workflows/test-redis-enterprise.yml index a84e1f78a..d8dff448e 100644 --- a/.github/workflows/test-redis-enterprise.yml +++ b/.github/workflows/test-redis-enterprise.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - go-version: [1.24.x] + go-version: [stable, "1.18"] re-build: ["7.4.2-54"] steps: From e6fff2367d3a5637e4cb8040d5515f99450cc0ff Mon Sep 17 00:00:00 2001 From: ccoVeille <3875889+ccoVeille@users.noreply.github.com> Date: Tue, 2 Dec 2025 13:35:01 +0100 Subject: [PATCH 2/3] fix: Go 1.18 supports was broken because of slices and maps usage These packages were only added to Go 1.21 --- doctests/query_em_test.go | 6 +++--- doctests/timeseries_tut_test.go | 33 +++++++++++++++++++++++++-------- maintnotifications/hooks.go | 14 ++++++++++++-- osscluster_test.go | 19 ++++++++++++++++--- 4 files changed, 56 insertions(+), 16 deletions(-) diff --git a/doctests/query_em_test.go b/doctests/query_em_test.go index feb918413..908441d9e 100644 --- a/doctests/query_em_test.go +++ b/doctests/query_em_test.go @@ -5,7 +5,7 @@ package example_commands_test import ( "context" "fmt" - "slices" + "sort" "strings" "github.com/redis/go-redis/v9" @@ -279,8 +279,8 @@ func ExampleClient_query_em() { fmt.Println(res3.Total) // >>> 5 docs := res3.Docs - slices.SortFunc(docs, func(a, b redis.Document) int { - return strings.Compare(a.ID, b.ID) + sort.Slice(docs, func(i, j int) bool { + return strings.Compare(docs[i].ID, docs[j].ID) < 0 }) for _, doc := range docs { diff --git a/doctests/timeseries_tut_test.go b/doctests/timeseries_tut_test.go index 28e163539..0b4e4152b 100644 --- a/doctests/timeseries_tut_test.go +++ b/doctests/timeseries_tut_test.go @@ -5,9 +5,7 @@ package example_commands_test import ( "context" "fmt" - "maps" "math" - "slices" "sort" "github.com/redis/go-redis/v9" @@ -417,7 +415,11 @@ func ExampleClient_timeseries_query_multi() { panic(err) } - res28Keys := slices.Collect(maps.Keys(res28)) + var res28Keys []string + for k := range res28 { + res28Keys = append(res28Keys, k) + } + sort.Strings(res28Keys) for _, k := range res28Keys { @@ -457,7 +459,10 @@ func ExampleClient_timeseries_query_multi() { panic(err) } - res29Keys := slices.Collect(maps.Keys(res29)) + var res29Keys []string + for k := range res29 { + res29Keys = append(res29Keys, k) + } sort.Strings(res29Keys) for _, k := range res29Keys { @@ -505,7 +510,10 @@ func ExampleClient_timeseries_query_multi() { panic(err) } - res30Keys := slices.Collect(maps.Keys(res30)) + var res30Keys []string + for k := range res30 { + res30Keys = append(res30Keys, k) + } sort.Strings(res30Keys) for _, k := range res30Keys { @@ -550,7 +558,10 @@ func ExampleClient_timeseries_query_multi() { panic(err) } - res31Keys := slices.Collect(maps.Keys(res31)) + var res31Keys []string + for k := range res31 { + res31Keys = append(res31Keys, k) + } sort.Strings(res31Keys) for _, k := range res31Keys { @@ -857,7 +868,10 @@ func ExampleClient_timeseries_aggmulti() { panic(err) } - res44Keys := slices.Collect(maps.Keys(res44)) + var res44Keys []string + for k := range res44 { + res44Keys = append(res44Keys, k) + } sort.Strings(res44Keys) for _, k := range res44Keys { @@ -905,7 +919,10 @@ func ExampleClient_timeseries_aggmulti() { panic(err) } - res45Keys := slices.Collect(maps.Keys(res45)) + var res45Keys []string + for k := range res45 { + res45Keys = append(res45Keys, k) + } sort.Strings(res45Keys) for _, k := range res45Keys { diff --git a/maintnotifications/hooks.go b/maintnotifications/hooks.go index ee3c3819c..bd8afc150 100644 --- a/maintnotifications/hooks.go +++ b/maintnotifications/hooks.go @@ -2,7 +2,6 @@ package maintnotifications import ( "context" - "slices" "github.com/redis/go-redis/v9/internal" "github.com/redis/go-redis/v9/internal/maintnotifications/logs" @@ -15,6 +14,17 @@ type LoggingHook struct { LogLevel int // 0=Error, 1=Warn, 2=Info, 3=Debug } +// slicesContains is an helper function to check if a slice contains a specific string. +// TODO: Replace with slices.Contains when we move to Go 1.21+ +func slicesContains(slice []string, item string) bool { + for _, s := range slice { + if s == item { + return true + } + } + return false +} + // PreHook logs the notification before processing and allows modification. func (lh *LoggingHook) PreHook(ctx context.Context, notificationCtx push.NotificationHandlerContext, notificationType string, notification []interface{}) ([]interface{}, bool) { if lh.LogLevel >= 2 { // Info level @@ -24,7 +34,7 @@ func (lh *LoggingHook) PreHook(ctx context.Context, notificationCtx push.Notific connID = conn.GetID() } seqID := int64(0) - if slices.Contains(maintenanceNotificationTypes, notificationType) { + if slicesContains(maintenanceNotificationTypes, notificationType) { // seqID is the second element in the notification array if len(notification) > 1 { if parsedSeqID, ok := notification[1].(int64); !ok { diff --git a/osscluster_test.go b/osscluster_test.go index d3dbd1f13..8cf9730a8 100644 --- a/osscluster_test.go +++ b/osscluster_test.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "net" - "slices" "strconv" "strings" "sync" @@ -107,6 +106,18 @@ func (s *clusterScenario) Close() error { return nil } +// slicesContains is an helper function to check if a slice contains a specific string. +// +// TODO: Replace with slices.Contains when we move to Go 1.21+ +func slicesContains(slice []string, item string) bool { + for _, s := range slice { + if s == item { + return true + } + } + return false +} + func configureClusterTopology(ctx context.Context, scenario *clusterScenario) error { allowErrs := []string{ "ERR Slot 0 is already busy", @@ -131,8 +142,10 @@ func configureClusterTopology(ctx context.Context, scenario *clusterScenario) er slots := scenario.slots() for pos, master := range scenario.masters() { err := master.ClusterAddSlotsRange(ctx, slots[pos], slots[pos+1]-1).Err() - if err != nil && slices.Contains(allowErrs, err.Error()) == false { - return err + if err != nil { + if !slicesContains(allowErrs, err.Error()) { + return err + } } } From 358c4e8a9d1c5318e4c24930eeb7e7480bee32ff Mon Sep 17 00:00:00 2001 From: ccoVeille <3875889+ccoVeille@users.noreply.github.com> Date: Tue, 2 Dec 2025 20:30:17 +0100 Subject: [PATCH 3/3] chore: add all versions to validate what could be the minimal go version --- .github/workflows/build.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index df686ad9a..7c9247bb4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -80,6 +80,13 @@ jobs: go-version: - "stable" # The latest stable Go release - "oldstable" # The previous Go release before stable + - "1.25.x" + - "1.24.x" + - "1.23.x" + - "1.22.x" + - "1.21.x" + - "1.20.x" + - "1.19.x" - "1.18.x" # Go 1.18 is the minimum supported version for go-redis (see go.mod) steps: