Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/run-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -78,8 +78,16 @@ jobs:
- "8.2.x" # Redis CE 8.2
- "8.0.x" # Redis CE 8.0
go-version:
- "1.23.x"
- "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:
- name: Checkout code
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/doctests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-redis-enterprise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions doctests/query_em_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package example_commands_test
import (
"context"
"fmt"
"slices"
"sort"
"strings"

"github.com/redis/go-redis/v9"
Expand Down Expand Up @@ -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 {
Expand Down
33 changes: 25 additions & 8 deletions doctests/timeseries_tut_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ package example_commands_test
import (
"context"
"fmt"
"maps"
"math"
"slices"
"sort"

"github.com/redis/go-redis/v9"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
14 changes: 12 additions & 2 deletions maintnotifications/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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 {
Expand Down
19 changes: 16 additions & 3 deletions osscluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"net"
"slices"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -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",
Expand All @@ -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
}
}
}

Expand Down
Loading