Skip to content

Commit cb031bd

Browse files
committed
fix: Go 1.18 supports was broken because of slices.Contains usage
1 parent f8992de commit cb031bd

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

maintnotifications/hooks.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package maintnotifications
22

33
import (
44
"context"
5-
"slices"
65

76
"github.com/redis/go-redis/v9/internal"
87
"github.com/redis/go-redis/v9/internal/maintnotifications/logs"
@@ -24,7 +23,7 @@ func (lh *LoggingHook) PreHook(ctx context.Context, notificationCtx push.Notific
2423
connID = conn.GetID()
2524
}
2625
seqID := int64(0)
27-
if slices.Contains(maintenanceNotificationTypes, notificationType) {
26+
if slicesContains(maintenanceNotificationTypes, notificationType) {
2827
// seqID is the second element in the notification array
2928
if len(notification) > 1 {
3029
if parsedSeqID, ok := notification[1].(int64); !ok {
@@ -40,6 +39,15 @@ func (lh *LoggingHook) PreHook(ctx context.Context, notificationCtx push.Notific
4039
return notification, true // Continue processing with unmodified notification
4140
}
4241

42+
func slicesContains(s []string, str string) bool {
43+
for _, v := range s {
44+
if v == str {
45+
return true
46+
}
47+
}
48+
return false
49+
}
50+
4351
// PostHook logs the result after processing.
4452
func (lh *LoggingHook) PostHook(ctx context.Context, notificationCtx push.NotificationHandlerContext, notificationType string, notification []interface{}, result error) {
4553
connID := uint64(0)

0 commit comments

Comments
 (0)