diff --git a/acl_commands_test.go b/acl_commands_test.go index a96621dbc..d0b994b4d 100644 --- a/acl_commands_test.go +++ b/acl_commands_test.go @@ -9,68 +9,69 @@ import ( . "github.com/bsm/gomega" ) -var TestUserName string = "goredis" -var _ = Describe("ACL", func() { - var client *redis.Client - var ctx context.Context - - BeforeEach(func() { - ctx = context.Background() - opt := redisOptions() - client = redis.NewClient(opt) - }) - - It("should ACL LOG", Label("NonRedisEnterprise"), func() { - Expect(client.ACLLogReset(ctx).Err()).NotTo(HaveOccurred()) - err := client.Do(ctx, "acl", "setuser", "test", ">test", "on", "allkeys", "+get").Err() - Expect(err).NotTo(HaveOccurred()) +var ( + TestUserName string = "goredis" + _ = Describe("ACL", func() { + var client *redis.Client + var ctx context.Context + + BeforeEach(func() { + ctx = context.Background() + opt := redisOptions() + client = redis.NewClient(opt) + }) + + It("should ACL LOG", Label("NonRedisEnterprise"), func() { + Expect(client.ACLLogReset(ctx).Err()).NotTo(HaveOccurred()) + err := client.Do(ctx, "acl", "setuser", "test", ">test", "on", "allkeys", "+get").Err() + Expect(err).NotTo(HaveOccurred()) - clientAcl := redis.NewClient(redisOptions()) - clientAcl.Options().Username = "test" - clientAcl.Options().Password = "test" - clientAcl.Options().DB = 0 - _ = clientAcl.Set(ctx, "mystring", "foo", 0).Err() - _ = clientAcl.HSet(ctx, "myhash", "foo", "bar").Err() - _ = clientAcl.SAdd(ctx, "myset", "foo", "bar").Err() + clientAcl := redis.NewClient(redisOptions()) + clientAcl.Options().Username = "test" + clientAcl.Options().Password = "test" + clientAcl.Options().DB = 0 + _ = clientAcl.Set(ctx, "mystring", "foo", 0).Err() + _ = clientAcl.HSet(ctx, "myhash", "foo", "bar").Err() + _ = clientAcl.SAdd(ctx, "myset", "foo", "bar").Err() - logEntries, err := client.ACLLog(ctx, 10).Result() - Expect(err).NotTo(HaveOccurred()) - Expect(len(logEntries)).To(Equal(4)) - - for _, entry := range logEntries { - Expect(entry.Reason).To(Equal("command")) - Expect(entry.Context).To(Equal("toplevel")) - Expect(entry.Object).NotTo(BeEmpty()) - Expect(entry.Username).To(Equal("test")) - Expect(entry.AgeSeconds).To(BeNumerically(">=", 0)) - Expect(entry.ClientInfo).NotTo(BeNil()) - Expect(entry.EntryID).To(BeNumerically(">=", 0)) - Expect(entry.TimestampCreated).To(BeNumerically(">=", 0)) - Expect(entry.TimestampLastUpdated).To(BeNumerically(">=", 0)) - } - - limitedLogEntries, err := client.ACLLog(ctx, 2).Result() - Expect(err).NotTo(HaveOccurred()) - Expect(len(limitedLogEntries)).To(Equal(2)) + logEntries, err := client.ACLLog(ctx, 10).Result() + Expect(err).NotTo(HaveOccurred()) + Expect(len(logEntries)).To(Equal(4)) + + for _, entry := range logEntries { + Expect(entry.Reason).To(Equal("command")) + Expect(entry.Context).To(Equal("toplevel")) + Expect(entry.Object).NotTo(BeEmpty()) + Expect(entry.Username).To(Equal("test")) + Expect(entry.AgeSeconds).To(BeNumerically(">=", 0)) + Expect(entry.ClientInfo).NotTo(BeNil()) + Expect(entry.EntryID).To(BeNumerically(">=", 0)) + Expect(entry.TimestampCreated).To(BeNumerically(">=", 0)) + Expect(entry.TimestampLastUpdated).To(BeNumerically(">=", 0)) + } + + limitedLogEntries, err := client.ACLLog(ctx, 2).Result() + Expect(err).NotTo(HaveOccurred()) + Expect(len(limitedLogEntries)).To(Equal(2)) - // cleanup after creating the user - err = client.Do(ctx, "acl", "deluser", "test").Err() - Expect(err).NotTo(HaveOccurred()) - }) + // cleanup after creating the user + err = client.Do(ctx, "acl", "deluser", "test").Err() + Expect(err).NotTo(HaveOccurred()) + }) - It("should ACL LOG RESET", Label("NonRedisEnterprise"), func() { - // Call ACL LOG RESET - resetCmd := client.ACLLogReset(ctx) - Expect(resetCmd.Err()).NotTo(HaveOccurred()) - Expect(resetCmd.Val()).To(Equal("OK")) + It("should ACL LOG RESET", Label("NonRedisEnterprise"), func() { + // Call ACL LOG RESET + resetCmd := client.ACLLogReset(ctx) + Expect(resetCmd.Err()).NotTo(HaveOccurred()) + Expect(resetCmd.Val()).To(Equal("OK")) - // Verify that the log is empty after the reset - logEntries, err := client.ACLLog(ctx, 10).Result() - Expect(err).NotTo(HaveOccurred()) - Expect(len(logEntries)).To(Equal(0)) + // Verify that the log is empty after the reset + logEntries, err := client.ACLLog(ctx, 10).Result() + Expect(err).NotTo(HaveOccurred()) + Expect(len(logEntries)).To(Equal(0)) + }) }) - -}) +) var _ = Describe("ACL user commands", Label("NonRedisEnterprise"), func() { var client *redis.Client var ctx context.Context diff --git a/bitmap_commands.go b/bitmap_commands.go index a21558289..3a9790518 100644 --- a/bitmap_commands.go +++ b/bitmap_commands.go @@ -12,7 +12,7 @@ type BitMapCmdable interface { BitOpAnd(ctx context.Context, destKey string, keys ...string) *IntCmd BitOpOr(ctx context.Context, destKey string, keys ...string) *IntCmd BitOpXor(ctx context.Context, destKey string, keys ...string) *IntCmd - BitOpNot(ctx context.Context, destKey string, key string) *IntCmd + BitOpNot(ctx context.Context, destKey, key string) *IntCmd BitPos(ctx context.Context, key string, bit int64, pos ...int64) *IntCmd BitPosSpan(ctx context.Context, key string, bit int8, start, end int64, span string) *IntCmd BitField(ctx context.Context, key string, values ...interface{}) *IntSliceCmd @@ -42,8 +42,10 @@ type BitCount struct { Unit string // BYTE(default) | BIT } -const BitCountIndexByte string = "BYTE" -const BitCountIndexBit string = "BIT" +const ( + BitCountIndexByte string = "BYTE" + BitCountIndexBit string = "BIT" +) func (c cmdable) BitCount(ctx context.Context, key string, bitCount *BitCount) *IntCmd { args := make([]any, 2, 5) @@ -90,7 +92,7 @@ func (c cmdable) BitOpXor(ctx context.Context, destKey string, keys ...string) * return c.bitOp(ctx, "xor", destKey, keys...) } -func (c cmdable) BitOpNot(ctx context.Context, destKey string, key string) *IntCmd { +func (c cmdable) BitOpNot(ctx context.Context, destKey, key string) *IntCmd { return c.bitOp(ctx, "not", destKey, key) } diff --git a/bitmap_commands_test.go b/bitmap_commands_test.go index f3cc3205f..14fc39603 100644 --- a/bitmap_commands_test.go +++ b/bitmap_commands_test.go @@ -3,6 +3,7 @@ package redis_test import ( . "github.com/bsm/ginkgo/v2" . "github.com/bsm/gomega" + "github.com/redis/go-redis/v9" ) @@ -31,7 +32,7 @@ var _ = Describe("BitCountBite", func() { }) It("bit count bite", func() { - var expected = []bitCountExpected{ + expected := []bitCountExpected{ {0, 0, 0}, {0, 1, 1}, {0, 2, 1}, @@ -71,7 +72,7 @@ var _ = Describe("BitCountByte", func() { }) It("bit count byte", func() { - var expected = []bitCountExpected{ + expected := []bitCountExpected{ {0, 0, 1}, {0, 1, 3}, } @@ -84,7 +85,7 @@ var _ = Describe("BitCountByte", func() { }) It("bit count byte with no unit specified", func() { - var expected = []bitCountExpected{ + expected := []bitCountExpected{ {0, 0, 1}, {0, 1, 3}, } diff --git a/cluster_commands.go b/cluster_commands.go index 4857b01ea..a0d5abdfe 100644 --- a/cluster_commands.go +++ b/cluster_commands.go @@ -16,7 +16,7 @@ type ClusterCmdable interface { ClusterResetHard(ctx context.Context) *StatusCmd ClusterInfo(ctx context.Context) *StringCmd ClusterKeySlot(ctx context.Context, key string) *IntCmd - ClusterGetKeysInSlot(ctx context.Context, slot int, count int) *StringSliceCmd + ClusterGetKeysInSlot(ctx context.Context, slot, count int) *StringSliceCmd ClusterCountFailureReports(ctx context.Context, nodeID string) *IntCmd ClusterCountKeysInSlot(ctx context.Context, slot int) *IntCmd ClusterDelSlots(ctx context.Context, slots ...int) *StatusCmd @@ -108,7 +108,7 @@ func (c cmdable) ClusterKeySlot(ctx context.Context, key string) *IntCmd { return cmd } -func (c cmdable) ClusterGetKeysInSlot(ctx context.Context, slot int, count int) *StringSliceCmd { +func (c cmdable) ClusterGetKeysInSlot(ctx context.Context, slot, count int) *StringSliceCmd { cmd := NewStringSliceCmd(ctx, "cluster", "getkeysinslot", slot, count) _ = c(ctx, cmd) return cmd diff --git a/command.go b/command.go index 364706e3e..7561cb2e9 100644 --- a/command.go +++ b/command.go @@ -2020,7 +2020,7 @@ type XInfoConsumer struct { var _ Cmder = (*XInfoConsumersCmd)(nil) -func NewXInfoConsumersCmd(ctx context.Context, stream string, group string) *XInfoConsumersCmd { +func NewXInfoConsumersCmd(ctx context.Context, stream, group string) *XInfoConsumersCmd { return &XInfoConsumersCmd{ baseCmd: baseCmd{ ctx: ctx, diff --git a/commands_test.go b/commands_test.go index 8b2aa37d4..1d45d07ea 100644 --- a/commands_test.go +++ b/commands_test.go @@ -342,7 +342,6 @@ var _ = Describe("Commands", func() { defer client2.Close() clientInfo = client2.ClientInfo(ctx).Val() Expect(clientInfo.LibName).To(ContainSubstring("go-redis(suffix,")) - }) It("should ConfigGet", func() { @@ -460,7 +459,7 @@ var _ = Describe("Commands", func() { } // read the defaults to set them back later - for setting, _ := range expected { + for setting := range expected { val, err := client.ConfigGet(ctx, setting).Result() Expect(err).NotTo(HaveOccurred()) defaults[setting] = val[setting] diff --git a/doctests/bf_tutorial_test.go b/doctests/bf_tutorial_test.go index bd7b310f2..740fd473a 100644 --- a/doctests/bf_tutorial_test.go +++ b/doctests/bf_tutorial_test.go @@ -28,7 +28,6 @@ func ExampleClient_bloom() { // STEP_START bloom res1, err := rdb.BFReserve(ctx, "bikes:models", 0.01, 1000).Result() - if err != nil { panic(err) } @@ -36,7 +35,6 @@ func ExampleClient_bloom() { fmt.Println(res1) // >>> OK res2, err := rdb.BFAdd(ctx, "bikes:models", "Smoky Mountain Striker").Result() - if err != nil { panic(err) } @@ -44,7 +42,6 @@ func ExampleClient_bloom() { fmt.Println(res2) // >>> true res3, err := rdb.BFExists(ctx, "bikes:models", "Smoky Mountain Striker").Result() - if err != nil { panic(err) } @@ -56,7 +53,6 @@ func ExampleClient_bloom() { "Cloudy City Cruiser", "Windy City Wippet", ).Result() - if err != nil { panic(err) } @@ -68,7 +64,6 @@ func ExampleClient_bloom() { "Cloudy City Cruiser", "Windy City Wippet", ).Result() - if err != nil { panic(err) } diff --git a/doctests/bitfield_tutorial_test.go b/doctests/bitfield_tutorial_test.go index 9693a6ec7..143350263 100644 --- a/doctests/bitfield_tutorial_test.go +++ b/doctests/bitfield_tutorial_test.go @@ -30,7 +30,6 @@ func ExampleClient_bf() { res1, err := rdb.BitField(ctx, "bike:1:stats", "set", "u32", "#0", "1000", ).Result() - if err != nil { panic(err) } @@ -42,7 +41,6 @@ func ExampleClient_bf() { "incrby", "u32", "#0", "-50", "incrby", "u32", "#1", "1", ).Result() - if err != nil { panic(err) } @@ -54,7 +52,6 @@ func ExampleClient_bf() { "incrby", "u32", "#0", "500", "incrby", "u32", "#1", "1", ).Result() - if err != nil { panic(err) } @@ -65,7 +62,6 @@ func ExampleClient_bf() { "get", "u32", "#0", "get", "u32", "#1", ).Result() - if err != nil { panic(err) } diff --git a/doctests/bitmap_tutorial_test.go b/doctests/bitmap_tutorial_test.go index c622f4b88..158e46f29 100644 --- a/doctests/bitmap_tutorial_test.go +++ b/doctests/bitmap_tutorial_test.go @@ -28,7 +28,6 @@ func ExampleClient_ping() { // STEP_START ping res1, err := rdb.SetBit(ctx, "pings:2024-01-01-00:00", 123, 1).Result() - if err != nil { panic(err) } @@ -36,7 +35,6 @@ func ExampleClient_ping() { fmt.Println(res1) // >>> 0 res2, err := rdb.GetBit(ctx, "pings:2024-01-01-00:00", 123).Result() - if err != nil { panic(err) } @@ -44,7 +42,6 @@ func ExampleClient_ping() { fmt.Println(res2) // >>> 1 res3, err := rdb.GetBit(ctx, "pings:2024-01-01-00:00", 456).Result() - if err != nil { panic(err) } @@ -71,7 +68,6 @@ func ExampleClient_bitcount() { // start with fresh database rdb.FlushDB(ctx) _, err := rdb.SetBit(ctx, "pings:2024-01-01-00:00", 123, 1).Result() - if err != nil { panic(err) } @@ -83,7 +79,6 @@ func ExampleClient_bitcount() { Start: 0, End: 456, }).Result() - if err != nil { panic(err) } diff --git a/doctests/cmds_generic_test.go b/doctests/cmds_generic_test.go index 18581e931..70a13cae5 100644 --- a/doctests/cmds_generic_test.go +++ b/doctests/cmds_generic_test.go @@ -30,7 +30,6 @@ func ExampleClient_del_cmd() { // STEP_START del delResult1, err := rdb.Set(ctx, "key1", "Hello", 0).Result() - if err != nil { panic(err) } @@ -38,7 +37,6 @@ func ExampleClient_del_cmd() { fmt.Println(delResult1) // >>> OK delResult2, err := rdb.Set(ctx, "key2", "World", 0).Result() - if err != nil { panic(err) } @@ -46,7 +44,6 @@ func ExampleClient_del_cmd() { fmt.Println(delResult2) // >>> OK delResult3, err := rdb.Del(ctx, "key1", "key2", "key3").Result() - if err != nil { panic(err) } @@ -77,7 +74,6 @@ func ExampleClient_expire_cmd() { // STEP_START expire expireResult1, err := rdb.Set(ctx, "mykey", "Hello", 0).Result() - if err != nil { panic(err) } @@ -85,7 +81,6 @@ func ExampleClient_expire_cmd() { fmt.Println(expireResult1) // >>> OK expireResult2, err := rdb.Expire(ctx, "mykey", 10*time.Second).Result() - if err != nil { panic(err) } @@ -93,7 +88,6 @@ func ExampleClient_expire_cmd() { fmt.Println(expireResult2) // >>> true expireResult3, err := rdb.TTL(ctx, "mykey").Result() - if err != nil { panic(err) } @@ -101,7 +95,6 @@ func ExampleClient_expire_cmd() { fmt.Println(math.Round(expireResult3.Seconds())) // >>> 10 expireResult4, err := rdb.Set(ctx, "mykey", "Hello World", 0).Result() - if err != nil { panic(err) } @@ -109,7 +102,6 @@ func ExampleClient_expire_cmd() { fmt.Println(expireResult4) // >>> OK expireResult5, err := rdb.TTL(ctx, "mykey").Result() - if err != nil { panic(err) } @@ -117,7 +109,6 @@ func ExampleClient_expire_cmd() { fmt.Println(expireResult5) // >>> -1ns expireResult6, err := rdb.ExpireXX(ctx, "mykey", 10*time.Second).Result() - if err != nil { panic(err) } @@ -125,7 +116,6 @@ func ExampleClient_expire_cmd() { fmt.Println(expireResult6) // >>> false expireResult7, err := rdb.TTL(ctx, "mykey").Result() - if err != nil { panic(err) } @@ -133,7 +123,6 @@ func ExampleClient_expire_cmd() { fmt.Println(expireResult7) // >>> -1ns expireResult8, err := rdb.ExpireNX(ctx, "mykey", 10*time.Second).Result() - if err != nil { panic(err) } @@ -141,7 +130,6 @@ func ExampleClient_expire_cmd() { fmt.Println(expireResult8) // >>> true expireResult9, err := rdb.TTL(ctx, "mykey").Result() - if err != nil { panic(err) } @@ -178,7 +166,6 @@ func ExampleClient_ttl_cmd() { // STEP_START ttl ttlResult1, err := rdb.Set(ctx, "mykey", "Hello", 10*time.Second).Result() - if err != nil { panic(err) } @@ -186,7 +173,6 @@ func ExampleClient_ttl_cmd() { fmt.Println(ttlResult1) // >>> OK ttlResult2, err := rdb.TTL(ctx, "mykey").Result() - if err != nil { panic(err) } diff --git a/doctests/cmds_hash_test.go b/doctests/cmds_hash_test.go index 8a4fdec42..9a49ab619 100644 --- a/doctests/cmds_hash_test.go +++ b/doctests/cmds_hash_test.go @@ -29,7 +29,6 @@ func ExampleClient_hset() { // STEP_START hset res1, err := rdb.HSet(ctx, "myhash", "field1", "Hello").Result() - if err != nil { panic(err) } @@ -37,7 +36,6 @@ func ExampleClient_hset() { fmt.Println(res1) // >>> 1 res2, err := rdb.HGet(ctx, "myhash", "field1").Result() - if err != nil { panic(err) } @@ -48,7 +46,6 @@ func ExampleClient_hset() { "field2", "Hi", "field3", "World", ).Result() - if err != nil { panic(err) } @@ -56,7 +53,6 @@ func ExampleClient_hset() { fmt.Println(res3) // >>> 2 res4, err := rdb.HGet(ctx, "myhash", "field2").Result() - if err != nil { panic(err) } @@ -64,7 +60,6 @@ func ExampleClient_hset() { fmt.Println(res4) // >>> Hi res5, err := rdb.HGet(ctx, "myhash", "field3").Result() - if err != nil { panic(err) } @@ -72,14 +67,13 @@ func ExampleClient_hset() { fmt.Println(res5) // >>> World res6, err := rdb.HGetAll(ctx, "myhash").Result() - if err != nil { panic(err) } keys := make([]string, 0, len(res6)) - for key, _ := range res6 { + for key := range res6 { keys = append(keys, key) } @@ -121,7 +115,6 @@ func ExampleClient_hget() { // STEP_START hget res7, err := rdb.HSet(ctx, "myhash", "field1", "foo").Result() - if err != nil { panic(err) } @@ -129,7 +122,6 @@ func ExampleClient_hget() { fmt.Println(res7) // >>> 1 res8, err := rdb.HGet(ctx, "myhash", "field1").Result() - if err != nil { panic(err) } @@ -137,7 +129,6 @@ func ExampleClient_hget() { fmt.Println(res8) // >>> foo res9, err := rdb.HGet(ctx, "myhash", "field2").Result() - if err != nil { fmt.Println(err) } @@ -171,7 +162,6 @@ func ExampleClient_hgetall() { "field1", "Hello", "field2", "World", ).Result() - if err != nil { panic(err) } @@ -179,14 +169,13 @@ func ExampleClient_hgetall() { fmt.Println(hGetAllResult1) // >>> 2 hGetAllResult2, err := rdb.HGetAll(ctx, "myhash").Result() - if err != nil { panic(err) } keys := make([]string, 0, len(hGetAllResult2)) - for key, _ := range hGetAllResult2 { + for key := range hGetAllResult2 { keys = append(keys, key) } @@ -225,7 +214,6 @@ func ExampleClient_hvals() { "field1", "Hello", "field2", "World", ).Result() - if err != nil { panic(err) } @@ -233,7 +221,6 @@ func ExampleClient_hvals() { fmt.Println(hValsResult1) // >>> 2 hValsResult2, err := rdb.HVals(ctx, "myhash").Result() - if err != nil { panic(err) } diff --git a/doctests/cmds_list_test.go b/doctests/cmds_list_test.go index ee4a40a0c..bc52afa24 100644 --- a/doctests/cmds_list_test.go +++ b/doctests/cmds_list_test.go @@ -26,7 +26,6 @@ func ExampleClient_cmd_llen() { // STEP_START llen lPushResult1, err := rdb.LPush(ctx, "mylist", "World").Result() - if err != nil { panic(err) } @@ -34,7 +33,6 @@ func ExampleClient_cmd_llen() { fmt.Println(lPushResult1) // >>> 1 lPushResult2, err := rdb.LPush(ctx, "mylist", "Hello").Result() - if err != nil { panic(err) } @@ -42,7 +40,6 @@ func ExampleClient_cmd_llen() { fmt.Println(lPushResult2) // >>> 2 lLenResult, err := rdb.LLen(ctx, "mylist").Result() - if err != nil { panic(err) } @@ -55,6 +52,7 @@ func ExampleClient_cmd_llen() { // 2 // 2 } + func ExampleClient_cmd_lpop() { ctx := context.Background() @@ -72,7 +70,6 @@ func ExampleClient_cmd_lpop() { RPushResult, err := rdb.RPush(ctx, "mylist", "one", "two", "three", "four", "five", ).Result() - if err != nil { panic(err) } @@ -80,7 +77,6 @@ func ExampleClient_cmd_lpop() { fmt.Println(RPushResult) // >>> 5 lPopResult, err := rdb.LPop(ctx, "mylist").Result() - if err != nil { panic(err) } @@ -88,7 +84,6 @@ func ExampleClient_cmd_lpop() { fmt.Println(lPopResult) // >>> one lPopCountResult, err := rdb.LPopCount(ctx, "mylist", 2).Result() - if err != nil { panic(err) } @@ -96,7 +91,6 @@ func ExampleClient_cmd_lpop() { fmt.Println(lPopCountResult) // >>> [two three] lRangeResult, err := rdb.LRange(ctx, "mylist", 0, -1).Result() - if err != nil { panic(err) } @@ -126,7 +120,6 @@ func ExampleClient_cmd_lpush() { // STEP_START lpush lPushResult1, err := rdb.LPush(ctx, "mylist", "World").Result() - if err != nil { panic(err) } @@ -134,7 +127,6 @@ func ExampleClient_cmd_lpush() { fmt.Println(lPushResult1) // >>> 1 lPushResult2, err := rdb.LPush(ctx, "mylist", "Hello").Result() - if err != nil { panic(err) } @@ -142,7 +134,6 @@ func ExampleClient_cmd_lpush() { fmt.Println(lPushResult2) // >>> 2 lRangeResult, err := rdb.LRange(ctx, "mylist", 0, -1).Result() - if err != nil { panic(err) } @@ -173,7 +164,6 @@ func ExampleClient_cmd_lrange() { RPushResult, err := rdb.RPush(ctx, "mylist", "one", "two", "three", ).Result() - if err != nil { panic(err) } @@ -181,7 +171,6 @@ func ExampleClient_cmd_lrange() { fmt.Println(RPushResult) // >>> 3 lRangeResult1, err := rdb.LRange(ctx, "mylist", 0, 0).Result() - if err != nil { panic(err) } @@ -189,7 +178,6 @@ func ExampleClient_cmd_lrange() { fmt.Println(lRangeResult1) // >>> [one] lRangeResult2, err := rdb.LRange(ctx, "mylist", -3, 2).Result() - if err != nil { panic(err) } @@ -197,7 +185,6 @@ func ExampleClient_cmd_lrange() { fmt.Println(lRangeResult2) // >>> [one two three] lRangeResult3, err := rdb.LRange(ctx, "mylist", -100, 100).Result() - if err != nil { panic(err) } @@ -205,7 +192,6 @@ func ExampleClient_cmd_lrange() { fmt.Println(lRangeResult3) // >>> [one two three] lRangeResult4, err := rdb.LRange(ctx, "mylist", 5, 10).Result() - if err != nil { panic(err) } @@ -238,7 +224,6 @@ func ExampleClient_cmd_rpop() { rPushResult, err := rdb.RPush(ctx, "mylist", "one", "two", "three", "four", "five", ).Result() - if err != nil { panic(err) } @@ -246,7 +231,6 @@ func ExampleClient_cmd_rpop() { fmt.Println(rPushResult) // >>> 5 rPopResult, err := rdb.RPop(ctx, "mylist").Result() - if err != nil { panic(err) } @@ -254,7 +238,6 @@ func ExampleClient_cmd_rpop() { fmt.Println(rPopResult) // >>> five rPopCountResult, err := rdb.RPopCount(ctx, "mylist", 2).Result() - if err != nil { panic(err) } @@ -262,7 +245,6 @@ func ExampleClient_cmd_rpop() { fmt.Println(rPopCountResult) // >>> [four three] lRangeResult, err := rdb.LRange(ctx, "mylist", 0, -1).Result() - if err != nil { panic(err) } @@ -292,7 +274,6 @@ func ExampleClient_cmd_rpush() { // STEP_START rpush rPushResult1, err := rdb.RPush(ctx, "mylist", "Hello").Result() - if err != nil { panic(err) } @@ -300,7 +281,6 @@ func ExampleClient_cmd_rpush() { fmt.Println(rPushResult1) // >>> 1 rPushResult2, err := rdb.RPush(ctx, "mylist", "World").Result() - if err != nil { panic(err) } @@ -308,7 +288,6 @@ func ExampleClient_cmd_rpush() { fmt.Println(rPushResult2) // >>> 2 lRangeResult, err := rdb.LRange(ctx, "mylist", 0, -1).Result() - if err != nil { panic(err) } diff --git a/doctests/cmds_servermgmt_test.go b/doctests/cmds_servermgmt_test.go index 0cd98f7dd..2e16c8f73 100644 --- a/doctests/cmds_servermgmt_test.go +++ b/doctests/cmds_servermgmt_test.go @@ -29,7 +29,6 @@ func ExampleClient_cmd_flushall() { rdb.Set(ctx, "testkey3", "3", 0) // REMOVE_END flushAllResult1, err := rdb.FlushAll(ctx).Result() - if err != nil { panic(err) } @@ -37,7 +36,6 @@ func ExampleClient_cmd_flushall() { fmt.Println(flushAllResult1) // >>> OK flushAllResult2, err := rdb.Keys(ctx, "*").Result() - if err != nil { panic(err) } @@ -61,7 +59,6 @@ func ExampleClient_cmd_info() { // STEP_START info infoResult, err := rdb.Info(ctx).Result() - if err != nil { panic(err) } diff --git a/doctests/cmds_set_test.go b/doctests/cmds_set_test.go index fecddbb83..22f22fd19 100644 --- a/doctests/cmds_set_test.go +++ b/doctests/cmds_set_test.go @@ -26,7 +26,6 @@ func ExampleClient_sadd_cmd() { // STEP_START sadd sAddResult1, err := rdb.SAdd(ctx, "myset", "Hello").Result() - if err != nil { panic(err) } @@ -34,7 +33,6 @@ func ExampleClient_sadd_cmd() { fmt.Println(sAddResult1) // >>> 1 sAddResult2, err := rdb.SAdd(ctx, "myset", "World").Result() - if err != nil { panic(err) } @@ -42,7 +40,6 @@ func ExampleClient_sadd_cmd() { fmt.Println(sAddResult2) // >>> 1 sAddResult3, err := rdb.SAdd(ctx, "myset", "World").Result() - if err != nil { panic(err) } @@ -50,7 +47,6 @@ func ExampleClient_sadd_cmd() { fmt.Println(sAddResult3) // >>> 0 sMembersResult, err := rdb.SMembers(ctx, "myset").Result() - if err != nil { panic(err) } @@ -80,7 +76,6 @@ func ExampleClient_smembers_cmd() { // STEP_START smembers sAddResult, err := rdb.SAdd(ctx, "myset", "Hello", "World").Result() - if err != nil { panic(err) } @@ -88,7 +83,6 @@ func ExampleClient_smembers_cmd() { fmt.Println(sAddResult) // >>> 2 sMembersResult, err := rdb.SMembers(ctx, "myset").Result() - if err != nil { panic(err) } diff --git a/doctests/cmds_sorted_set_test.go b/doctests/cmds_sorted_set_test.go index d781a2bb9..907eaa29d 100644 --- a/doctests/cmds_sorted_set_test.go +++ b/doctests/cmds_sorted_set_test.go @@ -30,7 +30,6 @@ func ExampleClient_zadd_cmd() { zAddResult1, err := rdb.ZAdd(ctx, "myzset", redis.Z{Member: "one", Score: 1}, ).Result() - if err != nil { panic(err) } @@ -40,7 +39,6 @@ func ExampleClient_zadd_cmd() { zAddResult2, err := rdb.ZAdd(ctx, "myzset", redis.Z{Member: "uno", Score: 1}, ).Result() - if err != nil { panic(err) } @@ -51,7 +49,6 @@ func ExampleClient_zadd_cmd() { redis.Z{Member: "two", Score: 2}, redis.Z{Member: "three", Score: 3}, ).Result() - if err != nil { panic(err) } @@ -59,7 +56,6 @@ func ExampleClient_zadd_cmd() { fmt.Println(zAddResult3) // >>> 2 zAddResult4, err := rdb.ZRangeWithScores(ctx, "myzset", 0, -1).Result() - if err != nil { panic(err) } @@ -95,7 +91,6 @@ func ExampleClient_zrange1() { redis.Z{Member: "two", Score: 2}, redis.Z{Member: "three", Score: 3}, ).Result() - if err != nil { panic(err) } @@ -103,7 +98,6 @@ func ExampleClient_zrange1() { fmt.Println(zrangeResult1) // >>> 3 zrangeResult2, err := rdb.ZRange(ctx, "myzset", 0, -1).Result() - if err != nil { panic(err) } @@ -111,7 +105,6 @@ func ExampleClient_zrange1() { fmt.Println(zrangeResult2) // >>> [one two three] zrangeResult3, err := rdb.ZRange(ctx, "myzset", 2, 3).Result() - if err != nil { panic(err) } @@ -119,7 +112,6 @@ func ExampleClient_zrange1() { fmt.Println(zrangeResult3) // >>> [three] zrangeResult4, err := rdb.ZRange(ctx, "myzset", -2, -1).Result() - if err != nil { panic(err) } @@ -155,7 +147,6 @@ func ExampleClient_zrange2() { redis.Z{Member: "two", Score: 2}, redis.Z{Member: "three", Score: 3}, ).Result() - if err != nil { panic(err) } @@ -163,7 +154,6 @@ func ExampleClient_zrange2() { fmt.Println(zRangeResult5) // >>> 3 zRangeResult6, err := rdb.ZRangeWithScores(ctx, "myzset", 0, 1).Result() - if err != nil { panic(err) } @@ -197,7 +187,6 @@ func ExampleClient_zrange3() { redis.Z{Member: "two", Score: 2}, redis.Z{Member: "three", Score: 3}, ).Result() - if err != nil { panic(err) } @@ -214,7 +203,6 @@ func ExampleClient_zrange3() { Count: 1, }, ).Result() - if err != nil { panic(err) } diff --git a/doctests/cmds_string_test.go b/doctests/cmds_string_test.go index 3808be9d3..e73ed44cf 100644 --- a/doctests/cmds_string_test.go +++ b/doctests/cmds_string_test.go @@ -28,7 +28,6 @@ func ExampleClient_cmd_incr() { // STEP_START incr incrResult1, err := rdb.Set(ctx, "mykey", "10", 0).Result() - if err != nil { panic(err) } @@ -36,7 +35,6 @@ func ExampleClient_cmd_incr() { fmt.Println(incrResult1) // >>> OK incrResult2, err := rdb.Incr(ctx, "mykey").Result() - if err != nil { panic(err) } @@ -44,7 +42,6 @@ func ExampleClient_cmd_incr() { fmt.Println(incrResult2) // >>> 11 incrResult3, err := rdb.Get(ctx, "mykey").Result() - if err != nil { panic(err) } diff --git a/doctests/cms_tutorial_test.go b/doctests/cms_tutorial_test.go index e84314a01..ce852e29d 100644 --- a/doctests/cms_tutorial_test.go +++ b/doctests/cms_tutorial_test.go @@ -28,7 +28,6 @@ func ExampleClient_cms() { // STEP_START cms res1, err := rdb.CMSInitByProb(ctx, "bikes:profit", 0.001, 0.002).Result() - if err != nil { panic(err) } @@ -38,7 +37,6 @@ func ExampleClient_cms() { res2, err := rdb.CMSIncrBy(ctx, "bikes:profit", "Smoky Mountain Striker", 100, ).Result() - if err != nil { panic(err) } @@ -49,7 +47,6 @@ func ExampleClient_cms() { "Rocky Mountain Racer", 200, "Cloudy City Cruiser", 150, ).Result() - if err != nil { panic(err) } @@ -59,7 +56,6 @@ func ExampleClient_cms() { res4, err := rdb.CMSQuery(ctx, "bikes:profit", "Smoky Mountain Striker", ).Result() - if err != nil { panic(err) } @@ -67,7 +63,6 @@ func ExampleClient_cms() { fmt.Println(res4) // >>> [100] res5, err := rdb.CMSInfo(ctx, "bikes:profit").Result() - if err != nil { panic(err) } diff --git a/doctests/cuckoo_tutorial_test.go b/doctests/cuckoo_tutorial_test.go index 4159d2ba4..77034b97b 100644 --- a/doctests/cuckoo_tutorial_test.go +++ b/doctests/cuckoo_tutorial_test.go @@ -28,7 +28,6 @@ func ExampleClient_cuckoo() { // STEP_START cuckoo res1, err := rdb.CFReserve(ctx, "bikes:models", 1000000).Result() - if err != nil { panic(err) } @@ -36,7 +35,6 @@ func ExampleClient_cuckoo() { fmt.Println(res1) // >>> OK res2, err := rdb.CFAdd(ctx, "bikes:models", "Smoky Mountain Striker").Result() - if err != nil { panic(err) } @@ -44,7 +42,6 @@ func ExampleClient_cuckoo() { fmt.Println(res2) // >>> true res3, err := rdb.CFExists(ctx, "bikes:models", "Smoky Mountain Striker").Result() - if err != nil { panic(err) } @@ -52,7 +49,6 @@ func ExampleClient_cuckoo() { fmt.Println(res3) // >>> true res4, err := rdb.CFExists(ctx, "bikes:models", "Terrible Bike Name").Result() - if err != nil { panic(err) } @@ -60,7 +56,6 @@ func ExampleClient_cuckoo() { fmt.Println(res4) // >>> false res5, err := rdb.CFDel(ctx, "bikes:models", "Smoky Mountain Striker").Result() - if err != nil { panic(err) } diff --git a/doctests/geo_index_test.go b/doctests/geo_index_test.go index c497b7224..21e9bbb96 100644 --- a/doctests/geo_index_test.go +++ b/doctests/geo_index_test.go @@ -42,7 +42,6 @@ func ExampleClient_geoindex() { FieldType: redis.SearchFieldTypeGeo, }, ).Result() - if err != nil { panic(err) } @@ -59,7 +58,6 @@ func ExampleClient_geoindex() { } gjResult1, err := rdb.JSONSet(ctx, "product:46885", "$", prd46885).Result() - if err != nil { panic(err) } @@ -74,7 +72,6 @@ func ExampleClient_geoindex() { } gjResult2, err := rdb.JSONSet(ctx, "product:46886", "$", prd46886).Result() - if err != nil { panic(err) } @@ -86,7 +83,6 @@ func ExampleClient_geoindex() { geoQueryResult, err := rdb.FTSearch(ctx, "productidx", "@location:[-104.800644 38.846127 100 mi]", ).Result() - if err != nil { panic(err) } @@ -113,7 +109,6 @@ func ExampleClient_geoindex() { GeoShapeFieldType: "FLAT", }, ).Result() - if err != nil { panic(err) } @@ -128,7 +123,6 @@ func ExampleClient_geoindex() { } gmjResult1, err := rdb.JSONSet(ctx, "shape:1", "$", shape1).Result() - if err != nil { panic(err) } @@ -141,7 +135,6 @@ func ExampleClient_geoindex() { } gmjResult2, err := rdb.JSONSet(ctx, "shape:2", "$", shape2).Result() - if err != nil { panic(err) } @@ -154,7 +147,6 @@ func ExampleClient_geoindex() { } gmjResult3, err := rdb.JSONSet(ctx, "shape:3", "$", shape3).Result() - if err != nil { panic(err) } @@ -167,7 +159,6 @@ func ExampleClient_geoindex() { } gmjResult4, err := rdb.JSONSet(ctx, "shape:4", "$", shape4).Result() - if err != nil { panic(err) } @@ -186,7 +177,6 @@ func ExampleClient_geoindex() { Limit: 1, }, ).Result() - if err != nil { panic(err) } diff --git a/doctests/geo_tutorial_test.go b/doctests/geo_tutorial_test.go index a3f6f1216..e966e1827 100644 --- a/doctests/geo_tutorial_test.go +++ b/doctests/geo_tutorial_test.go @@ -33,7 +33,6 @@ func ExampleClient_geoadd() { Latitude: 37.805186, Name: "station:1", }).Result() - if err != nil { panic(err) } @@ -46,7 +45,6 @@ func ExampleClient_geoadd() { Latitude: 37.8062344, Name: "station:2", }).Result() - if err != nil { panic(err) } @@ -59,7 +57,6 @@ func ExampleClient_geoadd() { Latitude: 37.8104049, Name: "station:3", }).Result() - if err != nil { panic(err) } @@ -93,7 +90,6 @@ func ExampleClient_geosearch() { Latitude: 37.805186, Name: "station:1", }).Result() - if err != nil { panic(err) } @@ -104,7 +100,6 @@ func ExampleClient_geosearch() { Latitude: 37.8062344, Name: "station:2", }).Result() - if err != nil { panic(err) } @@ -115,7 +110,6 @@ func ExampleClient_geosearch() { Latitude: 37.8104049, Name: "station:3", }).Result() - if err != nil { panic(err) } @@ -130,7 +124,6 @@ func ExampleClient_geosearch() { RadiusUnit: "km", }, ).Result() - if err != nil { panic(err) } diff --git a/doctests/hash_tutorial_test.go b/doctests/hash_tutorial_test.go index ebaa23fac..0c018d7f8 100644 --- a/doctests/hash_tutorial_test.go +++ b/doctests/hash_tutorial_test.go @@ -35,7 +35,6 @@ func ExampleClient_set_get_all() { } res1, err := rdb.HSet(ctx, "bike:1", hashFields).Result() - if err != nil { panic(err) } @@ -43,7 +42,6 @@ func ExampleClient_set_get_all() { fmt.Println(res1) // >>> 4 res2, err := rdb.HGet(ctx, "bike:1", "model").Result() - if err != nil { panic(err) } @@ -51,7 +49,6 @@ func ExampleClient_set_get_all() { fmt.Println(res2) // >>> Deimos res3, err := rdb.HGet(ctx, "bike:1", "price").Result() - if err != nil { panic(err) } @@ -60,7 +57,6 @@ func ExampleClient_set_get_all() { cmdReturn := rdb.HGetAll(ctx, "bike:1") res4, err := cmdReturn.Result() - if err != nil { panic(err) } @@ -117,7 +113,6 @@ func ExampleClient_hmget() { } _, err := rdb.HSet(ctx, "bike:1", hashFields).Result() - if err != nil { panic(err) } @@ -125,7 +120,6 @@ func ExampleClient_hmget() { // STEP_START hmget cmdReturn := rdb.HMGet(ctx, "bike:1", "model", "price") res5, err := cmdReturn.Result() - if err != nil { panic(err) } @@ -177,14 +171,12 @@ func ExampleClient_hincrby() { } _, err := rdb.HSet(ctx, "bike:1", hashFields).Result() - if err != nil { panic(err) } // STEP_START hincrby res6, err := rdb.HIncrBy(ctx, "bike:1", "price", 100).Result() - if err != nil { panic(err) } @@ -192,7 +184,6 @@ func ExampleClient_hincrby() { fmt.Println(res6) // >>> 5072 res7, err := rdb.HIncrBy(ctx, "bike:1", "price", -100).Result() - if err != nil { panic(err) } @@ -222,7 +213,6 @@ func ExampleClient_incrby_get_mget() { // STEP_START incrby_get_mget res8, err := rdb.HIncrBy(ctx, "bike:1:stats", "rides", 1).Result() - if err != nil { panic(err) } @@ -230,7 +220,6 @@ func ExampleClient_incrby_get_mget() { fmt.Println(res8) // >>> 1 res9, err := rdb.HIncrBy(ctx, "bike:1:stats", "rides", 1).Result() - if err != nil { panic(err) } @@ -238,7 +227,6 @@ func ExampleClient_incrby_get_mget() { fmt.Println(res9) // >>> 2 res10, err := rdb.HIncrBy(ctx, "bike:1:stats", "rides", 1).Result() - if err != nil { panic(err) } @@ -246,7 +234,6 @@ func ExampleClient_incrby_get_mget() { fmt.Println(res10) // >>> 3 res11, err := rdb.HIncrBy(ctx, "bike:1:stats", "crashes", 1).Result() - if err != nil { panic(err) } @@ -254,7 +241,6 @@ func ExampleClient_incrby_get_mget() { fmt.Println(res11) // >>> 1 res12, err := rdb.HIncrBy(ctx, "bike:1:stats", "owners", 1).Result() - if err != nil { panic(err) } @@ -262,7 +248,6 @@ func ExampleClient_incrby_get_mget() { fmt.Println(res12) // >>> 1 res13, err := rdb.HGet(ctx, "bike:1:stats", "rides").Result() - if err != nil { panic(err) } @@ -270,7 +255,6 @@ func ExampleClient_incrby_get_mget() { fmt.Println(res13) // >>> 3 res14, err := rdb.HMGet(ctx, "bike:1:stats", "crashes", "owners").Result() - if err != nil { panic(err) } diff --git a/doctests/hll_tutorial_test.go b/doctests/hll_tutorial_test.go index f8cd16dc7..c23b0c5d1 100644 --- a/doctests/hll_tutorial_test.go +++ b/doctests/hll_tutorial_test.go @@ -28,7 +28,6 @@ func ExampleClient_pfadd() { // STEP_START pfadd res1, err := rdb.PFAdd(ctx, "bikes", "Hyperion", "Deimos", "Phoebe", "Quaoar").Result() - if err != nil { panic(err) } @@ -36,7 +35,6 @@ func ExampleClient_pfadd() { fmt.Println(res1) // 1 res2, err := rdb.PFCount(ctx, "bikes").Result() - if err != nil { panic(err) } @@ -44,7 +42,6 @@ func ExampleClient_pfadd() { fmt.Println(res2) // 4 res3, err := rdb.PFAdd(ctx, "commuter_bikes", "Salacia", "Mimas", "Quaoar").Result() - if err != nil { panic(err) } @@ -52,7 +49,6 @@ func ExampleClient_pfadd() { fmt.Println(res3) // 1 res4, err := rdb.PFMerge(ctx, "all_bikes", "bikes", "commuter_bikes").Result() - if err != nil { panic(err) } @@ -60,7 +56,6 @@ func ExampleClient_pfadd() { fmt.Println(res4) // OK res5, err := rdb.PFCount(ctx, "all_bikes").Result() - if err != nil { panic(err) } diff --git a/doctests/home_json_example_test.go b/doctests/home_json_example_test.go index f32bf8d10..e6621b906 100644 --- a/doctests/home_json_example_test.go +++ b/doctests/home_json_example_test.go @@ -81,7 +81,6 @@ func ExampleClient_search_json() { FieldType: redis.SearchFieldTypeNumeric, }, ).Result() - if err != nil { panic(err) } @@ -89,19 +88,16 @@ func ExampleClient_search_json() { // STEP_START add_data _, err = rdb.JSONSet(ctx, "user:1", "$", user1).Result() - if err != nil { panic(err) } _, err = rdb.JSONSet(ctx, "user:2", "$", user2).Result() - if err != nil { panic(err) } _, err = rdb.JSONSet(ctx, "user:3", "$", user3).Result() - if err != nil { panic(err) } @@ -113,7 +109,6 @@ func ExampleClient_search_json() { "idx:users", "Paul @age:[30 40]", ).Result() - if err != nil { panic(err) } @@ -136,7 +131,6 @@ func ExampleClient_search_json() { }, }, ).Result() - if err != nil { panic(err) } @@ -167,7 +161,6 @@ func ExampleClient_search_json() { CountOnly: true, }, ).Result() - if err != nil { panic(err) } @@ -199,7 +192,6 @@ func ExampleClient_search_json() { "*", &aggOptions, ).Result() - if err != nil { panic(err) } diff --git a/doctests/json_tutorial_test.go b/doctests/json_tutorial_test.go index 5c2992573..c956183b3 100644 --- a/doctests/json_tutorial_test.go +++ b/doctests/json_tutorial_test.go @@ -29,7 +29,6 @@ func ExampleClient_setget() { res1, err := rdb.JSONSet(ctx, "bike", "$", "\"Hyperion\"", ).Result() - if err != nil { panic(err) } @@ -37,7 +36,6 @@ func ExampleClient_setget() { fmt.Println(res1) // >>> OK res2, err := rdb.JSONGet(ctx, "bike", "$").Result() - if err != nil { panic(err) } @@ -45,7 +43,6 @@ func ExampleClient_setget() { fmt.Println(res2) // >>> ["Hyperion"] res3, err := rdb.JSONType(ctx, "bike", "$").Result() - if err != nil { panic(err) } @@ -77,14 +74,12 @@ func ExampleClient_str() { _, err := rdb.JSONSet(ctx, "bike", "$", "\"Hyperion\"", ).Result() - if err != nil { panic(err) } // STEP_START str res4, err := rdb.JSONStrLen(ctx, "bike", "$").Result() - if err != nil { panic(err) } @@ -92,7 +87,6 @@ func ExampleClient_str() { fmt.Println(*res4[0]) // >>> 8 res5, err := rdb.JSONStrAppend(ctx, "bike", "$", "\" (Enduro bikes)\"").Result() - if err != nil { panic(err) } @@ -100,7 +94,6 @@ func ExampleClient_str() { fmt.Println(*res5[0]) // >>> 23 res6, err := rdb.JSONGet(ctx, "bike", "$").Result() - if err != nil { panic(err) } @@ -131,7 +124,6 @@ func ExampleClient_num() { // STEP_START num res7, err := rdb.JSONSet(ctx, "crashes", "$", 0).Result() - if err != nil { panic(err) } @@ -139,7 +131,6 @@ func ExampleClient_num() { fmt.Println(res7) // >>> OK res8, err := rdb.JSONNumIncrBy(ctx, "crashes", "$", 1).Result() - if err != nil { panic(err) } @@ -147,7 +138,6 @@ func ExampleClient_num() { fmt.Println(res8) // >>> [1] res9, err := rdb.JSONNumIncrBy(ctx, "crashes", "$", 1.5).Result() - if err != nil { panic(err) } @@ -155,7 +145,6 @@ func ExampleClient_num() { fmt.Println(res9) // >>> [2.5] res10, err := rdb.JSONNumIncrBy(ctx, "crashes", "$", -0.75).Result() - if err != nil { panic(err) } @@ -193,7 +182,6 @@ func ExampleClient_arr() { nil, }, ).Result() - if err != nil { panic(err) } @@ -201,7 +189,6 @@ func ExampleClient_arr() { fmt.Println(res11) // >>> OK res12, err := rdb.JSONGet(ctx, "newbike", "$").Result() - if err != nil { panic(err) } @@ -209,7 +196,6 @@ func ExampleClient_arr() { fmt.Println(res12) // >>> [["Deimos",{"crashes":0},null]] res13, err := rdb.JSONGet(ctx, "newbike", "$[1].crashes").Result() - if err != nil { panic(err) } @@ -217,7 +203,6 @@ func ExampleClient_arr() { fmt.Println(res13) // >>> [0] res14, err := rdb.JSONDel(ctx, "newbike", "$.[-1]").Result() - if err != nil { panic(err) } @@ -225,7 +210,6 @@ func ExampleClient_arr() { fmt.Println(res14) // >>> 1 res15, err := rdb.JSONGet(ctx, "newbike", "$").Result() - if err != nil { panic(err) } @@ -256,7 +240,6 @@ func ExampleClient_arr2() { // STEP_START arr2 res16, err := rdb.JSONSet(ctx, "riders", "$", []interface{}{}).Result() - if err != nil { panic(err) } @@ -264,7 +247,6 @@ func ExampleClient_arr2() { fmt.Println(res16) // >>> OK res17, err := rdb.JSONArrAppend(ctx, "riders", "$", "\"Norem\"").Result() - if err != nil { panic(err) } @@ -272,7 +254,6 @@ func ExampleClient_arr2() { fmt.Println(res17) // >>> [1] res18, err := rdb.JSONGet(ctx, "riders", "$").Result() - if err != nil { panic(err) } @@ -282,7 +263,6 @@ func ExampleClient_arr2() { res19, err := rdb.JSONArrInsert(ctx, "riders", "$", 1, "\"Prickett\"", "\"Royce\"", "\"Castilla\"", ).Result() - if err != nil { panic(err) } @@ -290,7 +270,6 @@ func ExampleClient_arr2() { fmt.Println(res19) // [3] res20, err := rdb.JSONGet(ctx, "riders", "$").Result() - if err != nil { panic(err) } @@ -302,7 +281,6 @@ func ExampleClient_arr2() { res21, err := rdb.JSONArrTrimWithArgs(ctx, "riders", "$", &redis.JSONArrTrimArgs{Start: 1, Stop: &rangeStop}, ).Result() - if err != nil { panic(err) } @@ -310,7 +288,6 @@ func ExampleClient_arr2() { fmt.Println(res21) // >>> [1] res22, err := rdb.JSONGet(ctx, "riders", "$").Result() - if err != nil { panic(err) } @@ -318,7 +295,6 @@ func ExampleClient_arr2() { fmt.Println(res22) // >>> [["Prickett"]] res23, err := rdb.JSONArrPop(ctx, "riders", "$", -1).Result() - if err != nil { panic(err) } @@ -326,7 +302,6 @@ func ExampleClient_arr2() { fmt.Println(res23) // >>> [["Prickett"]] res24, err := rdb.JSONArrPop(ctx, "riders", "$", -1).Result() - if err != nil { panic(err) } @@ -367,7 +342,6 @@ func ExampleClient_obj() { "price": 4972, }, ).Result() - if err != nil { panic(err) } @@ -375,7 +349,6 @@ func ExampleClient_obj() { fmt.Println(res25) // >>> OK res26, err := rdb.JSONObjLen(ctx, "bike:1", "$").Result() - if err != nil { panic(err) } @@ -383,7 +356,6 @@ func ExampleClient_obj() { fmt.Println(*res26[0]) // >>> 3 res27, err := rdb.JSONObjKeys(ctx, "bike:1", "$").Result() - if err != nil { panic(err) } @@ -483,7 +455,7 @@ func ExampleClient_setbikes() { // REMOVE_END // STEP_START set_bikes - var inventory_json = map[string]interface{}{ + inventory_json := map[string]interface{}{ "inventory": map[string]interface{}{ "mountain_bikes": []interface{}{ map[string]interface{}{ @@ -556,7 +528,6 @@ func ExampleClient_setbikes() { } res1, err := rdb.JSONSet(ctx, "bikes:inventory", "$", inventory_json).Result() - if err != nil { panic(err) } @@ -582,7 +553,6 @@ func ExampleClient_getbikes() { // REMOVE_END _, err := rdb.JSONSet(ctx, "bikes:inventory", "$", inventory_json).Result() - if err != nil { panic(err) } @@ -592,7 +562,6 @@ func ExampleClient_getbikes() { &redis.JSONGetArgs{Indent: " ", Newline: "\n", Space: " "}, "$.inventory.*", ).Result() - if err != nil { panic(err) } @@ -693,7 +662,6 @@ func ExampleClient_getmtnbikes() { // REMOVE_END _, err := rdb.JSONSet(ctx, "bikes:inventory", "$", inventory_json).Result() - if err != nil { panic(err) } @@ -702,7 +670,6 @@ func ExampleClient_getmtnbikes() { res3, err := rdb.JSONGet(ctx, "bikes:inventory", "$.inventory.mountain_bikes[*].model", ).Result() - if err != nil { panic(err) } @@ -713,7 +680,6 @@ func ExampleClient_getmtnbikes() { res4, err := rdb.JSONGet(ctx, "bikes:inventory", "$.inventory[\"mountain_bikes\"][*].model", ).Result() - if err != nil { panic(err) } @@ -724,7 +690,6 @@ func ExampleClient_getmtnbikes() { res5, err := rdb.JSONGet(ctx, "bikes:inventory", "$..mountain_bikes[*].model", ).Result() - if err != nil { panic(err) } @@ -753,14 +718,12 @@ func ExampleClient_getmodels() { // REMOVE_END _, err := rdb.JSONSet(ctx, "bikes:inventory", "$", inventory_json).Result() - if err != nil { panic(err) } // STEP_START get_models res6, err := rdb.JSONGet(ctx, "bikes:inventory", "$..model").Result() - if err != nil { panic(err) } @@ -786,14 +749,12 @@ func ExampleClient_get2mtnbikes() { // REMOVE_END _, err := rdb.JSONSet(ctx, "bikes:inventory", "$", inventory_json).Result() - if err != nil { panic(err) } // STEP_START get2mtnbikes res7, err := rdb.JSONGet(ctx, "bikes:inventory", "$..mountain_bikes[0:2].model").Result() - if err != nil { panic(err) } @@ -819,7 +780,6 @@ func ExampleClient_filter1() { // REMOVE_END _, err := rdb.JSONSet(ctx, "bikes:inventory", "$", inventory_json).Result() - if err != nil { panic(err) } @@ -829,7 +789,6 @@ func ExampleClient_filter1() { &redis.JSONGetArgs{Indent: " ", Newline: "\n", Space: " "}, "$..mountain_bikes[?(@.price < 3000 && @.specs.weight < 10)]", ).Result() - if err != nil { panic(err) } @@ -879,7 +838,6 @@ func ExampleClient_filter2() { // REMOVE_END _, err := rdb.JSONSet(ctx, "bikes:inventory", "$", inventory_json).Result() - if err != nil { panic(err) } @@ -889,7 +847,6 @@ func ExampleClient_filter2() { "bikes:inventory", "$..[?(@.specs.material == 'alloy')].model", ).Result() - if err != nil { panic(err) } @@ -915,7 +872,6 @@ func ExampleClient_filter3() { // REMOVE_END _, err := rdb.JSONSet(ctx, "bikes:inventory", "$", inventory_json).Result() - if err != nil { panic(err) } @@ -925,7 +881,6 @@ func ExampleClient_filter3() { "bikes:inventory", "$..[?(@.specs.material =~ '(?i)al')].model", ).Result() - if err != nil { panic(err) } @@ -951,7 +906,6 @@ func ExampleClient_filter4() { // REMOVE_END _, err := rdb.JSONSet(ctx, "bikes:inventory", "$", inventory_json).Result() - if err != nil { panic(err) } @@ -962,7 +916,6 @@ func ExampleClient_filter4() { "$.inventory.mountain_bikes[0].regex_pat", "\"(?i)al\"", ).Result() - if err != nil { panic(err) } @@ -974,7 +927,6 @@ func ExampleClient_filter4() { "$.inventory.mountain_bikes[1].regex_pat", "\"(?i)al\"", ).Result() - if err != nil { panic(err) } @@ -986,7 +938,6 @@ func ExampleClient_filter4() { "$.inventory.mountain_bikes[2].regex_pat", "\"(?i)al\"", ).Result() - if err != nil { panic(err) } @@ -997,7 +948,6 @@ func ExampleClient_filter4() { "bikes:inventory", "$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model", ).Result() - if err != nil { panic(err) } @@ -1026,14 +976,12 @@ func ExampleClient_updatebikes() { // REMOVE_END _, err := rdb.JSONSet(ctx, "bikes:inventory", "$", inventory_json).Result() - if err != nil { panic(err) } // STEP_START update_bikes res15, err := rdb.JSONGet(ctx, "bikes:inventory", "$..price").Result() - if err != nil { panic(err) } @@ -1041,7 +989,6 @@ func ExampleClient_updatebikes() { fmt.Println(res15) // >>> [1475,3941,1920,2072,3264] res16, err := rdb.JSONNumIncrBy(ctx, "bikes:inventory", "$..price", -100).Result() - if err != nil { panic(err) } @@ -1049,7 +996,6 @@ func ExampleClient_updatebikes() { fmt.Println(res16) // >>> [1375,3841,1820,1972,3164] res17, err := rdb.JSONNumIncrBy(ctx, "bikes:inventory", "$..price", 100).Result() - if err != nil { panic(err) } @@ -1077,7 +1023,6 @@ func ExampleClient_updatefilters1() { // REMOVE_END _, err := rdb.JSONSet(ctx, "bikes:inventory", "$", inventory_json).Result() - if err != nil { panic(err) } @@ -1088,7 +1033,6 @@ func ExampleClient_updatefilters1() { "$.inventory.*[?(@.price<2000)].price", 1500, ).Result() - if err != nil { panic(err) } @@ -1096,7 +1040,6 @@ func ExampleClient_updatefilters1() { fmt.Println(res18) // >>> OK res19, err := rdb.JSONGet(ctx, "bikes:inventory", "$..price").Result() - if err != nil { panic(err) } @@ -1123,7 +1066,6 @@ func ExampleClient_updatefilters2() { // REMOVE_END _, err := rdb.JSONSet(ctx, "bikes:inventory", "$", inventory_json).Result() - if err != nil { panic(err) } @@ -1134,7 +1076,6 @@ func ExampleClient_updatefilters2() { "$.inventory.*[?(@.price<2000)].colors", "\"pink\"", ).Result() - if err != nil { panic(err) } @@ -1142,7 +1083,6 @@ func ExampleClient_updatefilters2() { fmt.Println(res20) // >>> [3 3] res21, err := rdb.JSONGet(ctx, "bikes:inventory", "$..[*].colors").Result() - if err != nil { panic(err) } diff --git a/doctests/list_tutorial_test.go b/doctests/list_tutorial_test.go index 1df413d4b..98ee6e96d 100644 --- a/doctests/list_tutorial_test.go +++ b/doctests/list_tutorial_test.go @@ -28,7 +28,6 @@ func ExampleClient_queue() { // STEP_START queue res1, err := rdb.LPush(ctx, "bikes:repairs", "bike:1").Result() - if err != nil { panic(err) } @@ -36,7 +35,6 @@ func ExampleClient_queue() { fmt.Println(res1) // >>> 1 res2, err := rdb.LPush(ctx, "bikes:repairs", "bike:2").Result() - if err != nil { panic(err) } @@ -44,7 +42,6 @@ func ExampleClient_queue() { fmt.Println(res2) // >>> 2 res3, err := rdb.RPop(ctx, "bikes:repairs").Result() - if err != nil { panic(err) } @@ -52,7 +49,6 @@ func ExampleClient_queue() { fmt.Println(res3) // >>> bike:1 res4, err := rdb.RPop(ctx, "bikes:repairs").Result() - if err != nil { panic(err) } @@ -84,7 +80,6 @@ func ExampleClient_stack() { // STEP_START stack res5, err := rdb.LPush(ctx, "bikes:repairs", "bike:1").Result() - if err != nil { panic(err) } @@ -92,7 +87,6 @@ func ExampleClient_stack() { fmt.Println(res5) // >>> 1 res6, err := rdb.LPush(ctx, "bikes:repairs", "bike:2").Result() - if err != nil { panic(err) } @@ -100,7 +94,6 @@ func ExampleClient_stack() { fmt.Println(res6) // >>> 2 res7, err := rdb.LPop(ctx, "bikes:repairs").Result() - if err != nil { panic(err) } @@ -108,7 +101,6 @@ func ExampleClient_stack() { fmt.Println(res7) // >>> bike:2 res8, err := rdb.LPop(ctx, "bikes:repairs").Result() - if err != nil { panic(err) } @@ -140,7 +132,6 @@ func ExampleClient_llen() { // STEP_START llen res9, err := rdb.LLen(ctx, "bikes:repairs").Result() - if err != nil { panic(err) } @@ -170,7 +161,6 @@ func ExampleClient_lmove_lrange() { // STEP_START lmove_lrange res10, err := rdb.LPush(ctx, "bikes:repairs", "bike:1").Result() - if err != nil { panic(err) } @@ -178,7 +168,6 @@ func ExampleClient_lmove_lrange() { fmt.Println(res10) // >>> 1 res11, err := rdb.LPush(ctx, "bikes:repairs", "bike:2").Result() - if err != nil { panic(err) } @@ -186,7 +175,6 @@ func ExampleClient_lmove_lrange() { fmt.Println(res11) // >>> 2 res12, err := rdb.LMove(ctx, "bikes:repairs", "bikes:finished", "LEFT", "LEFT").Result() - if err != nil { panic(err) } @@ -194,7 +182,6 @@ func ExampleClient_lmove_lrange() { fmt.Println(res12) // >>> bike:2 res13, err := rdb.LRange(ctx, "bikes:repairs", 0, -1).Result() - if err != nil { panic(err) } @@ -202,7 +189,6 @@ func ExampleClient_lmove_lrange() { fmt.Println(res13) // >>> [bike:1] res14, err := rdb.LRange(ctx, "bikes:finished", 0, -1).Result() - if err != nil { panic(err) } @@ -235,7 +221,6 @@ func ExampleClient_lpush_rpush() { // STEP_START lpush_rpush res15, err := rdb.RPush(ctx, "bikes:repairs", "bike:1").Result() - if err != nil { panic(err) } @@ -243,7 +228,6 @@ func ExampleClient_lpush_rpush() { fmt.Println(res15) // >>> 1 res16, err := rdb.RPush(ctx, "bikes:repairs", "bike:2").Result() - if err != nil { panic(err) } @@ -251,7 +235,6 @@ func ExampleClient_lpush_rpush() { fmt.Println(res16) // >>> 2 res17, err := rdb.LPush(ctx, "bikes:repairs", "bike:important_bike").Result() - if err != nil { panic(err) } @@ -259,7 +242,6 @@ func ExampleClient_lpush_rpush() { fmt.Println(res17) // >>> 3 res18, err := rdb.LRange(ctx, "bikes:repairs", 0, -1).Result() - if err != nil { panic(err) } @@ -291,7 +273,6 @@ func ExampleClient_variadic() { // STEP_START variadic res19, err := rdb.RPush(ctx, "bikes:repairs", "bike:1", "bike:2", "bike:3").Result() - if err != nil { panic(err) } @@ -299,7 +280,6 @@ func ExampleClient_variadic() { fmt.Println(res19) // >>> 3 res20, err := rdb.LPush(ctx, "bikes:repairs", "bike:important_bike", "bike:very_important_bike").Result() - if err != nil { panic(err) } @@ -307,7 +287,6 @@ func ExampleClient_variadic() { fmt.Println(res20) // >>> 5 res21, err := rdb.LRange(ctx, "bikes:repairs", 0, -1).Result() - if err != nil { panic(err) } @@ -338,7 +317,6 @@ func ExampleClient_lpop_rpop() { // STEP_START lpop_rpop res22, err := rdb.RPush(ctx, "bikes:repairs", "bike:1", "bike:2", "bike:3").Result() - if err != nil { panic(err) } @@ -346,7 +324,6 @@ func ExampleClient_lpop_rpop() { fmt.Println(res22) // >>> 3 res23, err := rdb.RPop(ctx, "bikes:repairs").Result() - if err != nil { panic(err) } @@ -354,7 +331,6 @@ func ExampleClient_lpop_rpop() { fmt.Println(res23) // >>> bike:3 res24, err := rdb.LPop(ctx, "bikes:repairs").Result() - if err != nil { panic(err) } @@ -362,7 +338,6 @@ func ExampleClient_lpop_rpop() { fmt.Println(res24) // >>> bike:1 res25, err := rdb.RPop(ctx, "bikes:repairs").Result() - if err != nil { panic(err) } @@ -370,7 +345,6 @@ func ExampleClient_lpop_rpop() { fmt.Println(res25) // >>> bike:2 res26, err := rdb.RPop(ctx, "bikes:repairs").Result() - if err != nil { fmt.Println(err) // >>> redis: nil } @@ -405,7 +379,6 @@ func ExampleClient_ltrim() { // STEP_START ltrim res27, err := rdb.RPush(ctx, "bikes:repairs", "bike:1", "bike:2", "bike:3", "bike:4", "bike:5").Result() - if err != nil { panic(err) } @@ -413,7 +386,6 @@ func ExampleClient_ltrim() { fmt.Println(res27) // >>> 5 res28, err := rdb.LTrim(ctx, "bikes:repairs", 0, 2).Result() - if err != nil { panic(err) } @@ -421,7 +393,6 @@ func ExampleClient_ltrim() { fmt.Println(res28) // >>> OK res29, err := rdb.LRange(ctx, "bikes:repairs", 0, -1).Result() - if err != nil { panic(err) } @@ -452,7 +423,6 @@ func ExampleClient_ltrim_end_of_list() { // STEP_START ltrim_end_of_list res30, err := rdb.RPush(ctx, "bikes:repairs", "bike:1", "bike:2", "bike:3", "bike:4", "bike:5").Result() - if err != nil { panic(err) } @@ -460,7 +430,6 @@ func ExampleClient_ltrim_end_of_list() { fmt.Println(res30) // >>> 5 res31, err := rdb.LTrim(ctx, "bikes:repairs", -3, -1).Result() - if err != nil { panic(err) } @@ -468,7 +437,6 @@ func ExampleClient_ltrim_end_of_list() { fmt.Println(res31) // >>> OK res32, err := rdb.LRange(ctx, "bikes:repairs", 0, -1).Result() - if err != nil { panic(err) } @@ -499,7 +467,6 @@ func ExampleClient_brpop() { // STEP_START brpop res33, err := rdb.RPush(ctx, "bikes:repairs", "bike:1", "bike:2").Result() - if err != nil { panic(err) } @@ -507,7 +474,6 @@ func ExampleClient_brpop() { fmt.Println(res33) // >>> 2 res34, err := rdb.BRPop(ctx, 1, "bikes:repairs").Result() - if err != nil { panic(err) } @@ -515,7 +481,6 @@ func ExampleClient_brpop() { fmt.Println(res34) // >>> [bikes:repairs bike:2] res35, err := rdb.BRPop(ctx, 1, "bikes:repairs").Result() - if err != nil { panic(err) } @@ -523,7 +488,6 @@ func ExampleClient_brpop() { fmt.Println(res35) // >>> [bikes:repairs bike:1] res36, err := rdb.BRPop(ctx, 1, "bikes:repairs").Result() - if err != nil { fmt.Println(err) // >>> redis: nil } @@ -556,7 +520,6 @@ func ExampleClient_rule1() { // STEP_START rule_1 res37, err := rdb.Del(ctx, "new_bikes").Result() - if err != nil { panic(err) } @@ -564,7 +527,6 @@ func ExampleClient_rule1() { fmt.Println(res37) // >>> 0 res38, err := rdb.LPush(ctx, "new_bikes", "bike:1", "bike:2", "bike:3").Result() - if err != nil { panic(err) } @@ -592,7 +554,6 @@ func ExampleClient_rule11() { // STEP_START rule_1.1 res39, err := rdb.Set(ctx, "new_bikes", "bike:1", 0).Result() - if err != nil { panic(err) } @@ -600,7 +561,6 @@ func ExampleClient_rule11() { fmt.Println(res39) // >>> OK res40, err := rdb.Type(ctx, "new_bikes").Result() - if err != nil { panic(err) } @@ -608,7 +568,6 @@ func ExampleClient_rule11() { fmt.Println(res40) // >>> string res41, err := rdb.LPush(ctx, "new_bikes", "bike:2", "bike:3").Result() - if err != nil { fmt.Println(err) // >>> WRONGTYPE Operation against a key holding the wrong kind of value @@ -639,7 +598,6 @@ func ExampleClient_rule2() { // STEP_START rule_2 res42, err := rdb.LPush(ctx, "bikes:repairs", "bike:1", "bike:2", "bike:3").Result() - if err != nil { panic(err) } @@ -647,7 +605,6 @@ func ExampleClient_rule2() { fmt.Println(res42) // >>> 3 res43, err := rdb.Exists(ctx, "bikes:repairs").Result() - if err != nil { panic(err) } @@ -655,7 +612,6 @@ func ExampleClient_rule2() { fmt.Println(res43) // >>> 1 res44, err := rdb.LPop(ctx, "bikes:repairs").Result() - if err != nil { panic(err) } @@ -663,7 +619,6 @@ func ExampleClient_rule2() { fmt.Println(res44) // >>> bike:3 res45, err := rdb.LPop(ctx, "bikes:repairs").Result() - if err != nil { panic(err) } @@ -671,7 +626,6 @@ func ExampleClient_rule2() { fmt.Println(res45) // >>> bike:2 res46, err := rdb.LPop(ctx, "bikes:repairs").Result() - if err != nil { panic(err) } @@ -679,7 +633,6 @@ func ExampleClient_rule2() { fmt.Println(res46) // >>> bike:1 res47, err := rdb.Exists(ctx, "bikes:repairs").Result() - if err != nil { panic(err) } @@ -711,7 +664,6 @@ func ExampleClient_rule3() { // STEP_START rule_3 res48, err := rdb.Del(ctx, "bikes:repairs").Result() - if err != nil { panic(err) } @@ -719,7 +671,6 @@ func ExampleClient_rule3() { fmt.Println(res48) // >>> 0 res49, err := rdb.LLen(ctx, "bikes:repairs").Result() - if err != nil { panic(err) } @@ -727,7 +678,6 @@ func ExampleClient_rule3() { fmt.Println(res49) // >>> 0 res50, err := rdb.LPop(ctx, "bikes:repairs").Result() - if err != nil { fmt.Println(err) // >>> redis: nil } @@ -757,7 +707,6 @@ func ExampleClient_ltrim1() { // STEP_START ltrim.1 res51, err := rdb.LPush(ctx, "bikes:repairs", "bike:1", "bike:2", "bike:3", "bike:4", "bike:5").Result() - if err != nil { panic(err) } @@ -765,7 +714,6 @@ func ExampleClient_ltrim1() { fmt.Println(res51) // >>> 5 res52, err := rdb.LTrim(ctx, "bikes:repairs", 0, 2).Result() - if err != nil { panic(err) } @@ -773,7 +721,6 @@ func ExampleClient_ltrim1() { fmt.Println(res52) // >>> OK res53, err := rdb.LRange(ctx, "bikes:repairs", 0, -1).Result() - if err != nil { panic(err) } diff --git a/doctests/pipe_trans_example_test.go b/doctests/pipe_trans_example_test.go index 4ce3840ff..e503c2da8 100644 --- a/doctests/pipe_trans_example_test.go +++ b/doctests/pipe_trans_example_test.go @@ -37,7 +37,6 @@ func ExampleClient_transactions() { } cmds, err := pipe.Exec(ctx) - if err != nil { panic(err) } @@ -75,7 +74,6 @@ func ExampleClient_transactions() { pd4Result = (*redis.StatusCmd)(pipe.Get(ctx, "seat:4")) return nil }) - if err != nil { panic(err) } @@ -115,7 +113,6 @@ func ExampleClient_transactions() { tx3Result = trans.IncrBy(ctx, "counter:3", 3) return nil }) - if err != nil { panic(err) } diff --git a/doctests/query_agg_test.go b/doctests/query_agg_test.go index baa5dfbae..1da3c6323 100644 --- a/doctests/query_agg_test.go +++ b/doctests/query_agg_test.go @@ -58,7 +58,6 @@ func ExampleClient_query_agg() { FieldType: redis.SearchFieldTypeTag, }, ).Result() - if err != nil { panic(err) } @@ -217,7 +216,6 @@ func ExampleClient_query_agg() { for i, json := range exampleJsons { _, err := rdb.JSONSet(ctx, fmt.Sprintf("bicycle:%v", i), "$", json).Result() - if err != nil { panic(err) } @@ -240,7 +238,6 @@ func ExampleClient_query_agg() { }, }, ).Result() - if err != nil { panic(err) } @@ -294,7 +291,6 @@ func ExampleClient_query_agg() { }, }, ).Result() - if err != nil { panic(err) } @@ -342,7 +338,6 @@ func ExampleClient_query_agg() { }, }, ).Result() - if err != nil { panic(err) } @@ -380,7 +375,6 @@ func ExampleClient_query_agg() { }, }, ).Result() - if err != nil { panic(err) } diff --git a/doctests/query_em_test.go b/doctests/query_em_test.go index feb918413..24b7efba7 100644 --- a/doctests/query_em_test.go +++ b/doctests/query_em_test.go @@ -60,7 +60,6 @@ func ExampleClient_query_em() { FieldType: redis.SearchFieldTypeTag, }, ).Result() - if err != nil { panic(err) } @@ -219,7 +218,6 @@ func ExampleClient_query_em() { for i, json := range exampleJsons { _, err := rdb.JSONSet(ctx, fmt.Sprintf("bicycle:%v", i), "$", json).Result() - if err != nil { panic(err) } @@ -229,7 +227,6 @@ func ExampleClient_query_em() { res1, err := rdb.FTSearch(ctx, "idx:bicycle", "@price:[270 270]", ).Result() - if err != nil { panic(err) } @@ -254,7 +251,6 @@ func ExampleClient_query_em() { }, }, ).Result() - if err != nil { panic(err) } @@ -271,7 +267,6 @@ func ExampleClient_query_em() { res3, err := rdb.FTSearch(ctx, "idx:bicycle", "@condition:{new}", ).Result() - if err != nil { panic(err) } @@ -306,7 +301,6 @@ func ExampleClient_query_em() { FieldType: redis.SearchFieldTypeTag, }, ).Result() - if err != nil { panic(err) } @@ -318,7 +312,6 @@ func ExampleClient_query_em() { "email": "test@redis.com", }, ).Result() - if err != nil { panic(err) } @@ -328,7 +321,6 @@ func ExampleClient_query_em() { res6, err := rdb.FTSearch(ctx, "idx:email", "@email:{test\\@redis\\.com}", ).Result() - if err != nil { panic(err) } @@ -340,7 +332,6 @@ func ExampleClient_query_em() { res7, err := rdb.FTSearch(ctx, "idx:bicycle", "@description:\"rough terrain\"", ).Result() - if err != nil { panic(err) } diff --git a/doctests/query_ft_test.go b/doctests/query_ft_test.go index 0b3710a97..14d9d24bc 100644 --- a/doctests/query_ft_test.go +++ b/doctests/query_ft_test.go @@ -58,7 +58,6 @@ func ExampleClient_query_ft() { FieldType: redis.SearchFieldTypeTag, }, ).Result() - if err != nil { panic(err) } @@ -217,7 +216,6 @@ func ExampleClient_query_ft() { for i, json := range exampleJsons { _, err := rdb.JSONSet(ctx, fmt.Sprintf("bicycle:%v", i), "$", json).Result() - if err != nil { panic(err) } @@ -227,7 +225,6 @@ func ExampleClient_query_ft() { res1, err := rdb.FTSearch(ctx, "idx:bicycle", "@description: kids", ).Result() - if err != nil { panic(err) } @@ -249,7 +246,6 @@ func ExampleClient_query_ft() { res2, err := rdb.FTSearch(ctx, "idx:bicycle", "@model: ka*", ).Result() - if err != nil { panic(err) } @@ -266,7 +262,6 @@ func ExampleClient_query_ft() { res3, err := rdb.FTSearch(ctx, "idx:bicycle", "@brand: *bikes", ).Result() - if err != nil { panic(err) } @@ -287,7 +282,6 @@ func ExampleClient_query_ft() { res4, err := rdb.FTSearch(ctx, "idx:bicycle", "%optamized%", ).Result() - if err != nil { panic(err) } @@ -304,7 +298,6 @@ func ExampleClient_query_ft() { res5, err := rdb.FTSearch(ctx, "idx:bicycle", "%%optamised%%", ).Result() - if err != nil { panic(err) } diff --git a/doctests/query_geo_test.go b/doctests/query_geo_test.go index b0287e0fb..e89397b85 100644 --- a/doctests/query_geo_test.go +++ b/doctests/query_geo_test.go @@ -68,7 +68,6 @@ func ExampleClient_query_geo() { GeoShapeFieldType: "FLAT", }, ).Result() - if err != nil { panic(err) } @@ -227,7 +226,6 @@ func ExampleClient_query_geo() { for i, json := range exampleJsons { _, err := rdb.JSONSet(ctx, fmt.Sprintf("bicycle:%v", i), "$", json).Result() - if err != nil { panic(err) } @@ -246,7 +244,6 @@ func ExampleClient_query_geo() { DialectVersion: 2, }, ).Result() - if err != nil { panic(err) } @@ -270,7 +267,6 @@ func ExampleClient_query_geo() { DialectVersion: 3, }, ).Result() - if err != nil { panic(err) } @@ -294,7 +290,6 @@ func ExampleClient_query_geo() { DialectVersion: 3, }, ).Result() - if err != nil { panic(err) } diff --git a/doctests/query_range_test.go b/doctests/query_range_test.go index 09b3bb619..49a2b2ee5 100644 --- a/doctests/query_range_test.go +++ b/doctests/query_range_test.go @@ -56,7 +56,6 @@ func ExampleClient_query_range() { FieldType: redis.SearchFieldTypeTag, }, ).Result() - if err != nil { panic(err) } @@ -215,7 +214,6 @@ func ExampleClient_query_range() { for i, json := range exampleJsons { _, err := rdb.JSONSet(ctx, fmt.Sprintf("bicycle:%v", i), "$", json).Result() - if err != nil { panic(err) } @@ -238,7 +236,6 @@ func ExampleClient_query_range() { }, }, ).Result() - if err != nil { panic(err) } @@ -277,7 +274,6 @@ func ExampleClient_query_range() { }, }, ).Result() - if err != nil { panic(err) } @@ -316,7 +312,6 @@ func ExampleClient_query_range() { }, }, ).Result() - if err != nil { panic(err) } @@ -353,7 +348,6 @@ func ExampleClient_query_range() { Limit: 5, }, ).Result() - if err != nil { panic(err) } diff --git a/doctests/sets_example_test.go b/doctests/sets_example_test.go index 15cabf0ad..9853113b6 100644 --- a/doctests/sets_example_test.go +++ b/doctests/sets_example_test.go @@ -29,7 +29,6 @@ func ExampleClient_sadd() { // STEP_START sadd res1, err := rdb.SAdd(ctx, "bikes:racing:france", "bike:1").Result() - if err != nil { panic(err) } @@ -37,7 +36,6 @@ func ExampleClient_sadd() { fmt.Println(res1) // >>> 1 res2, err := rdb.SAdd(ctx, "bikes:racing:france", "bike:1").Result() - if err != nil { panic(err) } @@ -45,7 +43,6 @@ func ExampleClient_sadd() { fmt.Println(res2) // >>> 0 res3, err := rdb.SAdd(ctx, "bikes:racing:france", "bike:2", "bike:3").Result() - if err != nil { panic(err) } @@ -53,7 +50,6 @@ func ExampleClient_sadd() { fmt.Println(res3) // >>> 2 res4, err := rdb.SAdd(ctx, "bikes:racing:usa", "bike:1", "bike:4").Result() - if err != nil { panic(err) } @@ -85,20 +81,17 @@ func ExampleClient_sismember() { // REMOVE_END _, err := rdb.SAdd(ctx, "bikes:racing:france", "bike:1", "bike:2", "bike:3").Result() - if err != nil { panic(err) } _, err = rdb.SAdd(ctx, "bikes:racing:usa", "bike:1", "bike:4").Result() - if err != nil { panic(err) } // STEP_START sismember res5, err := rdb.SIsMember(ctx, "bikes:racing:usa", "bike:1").Result() - if err != nil { panic(err) } @@ -106,7 +99,6 @@ func ExampleClient_sismember() { fmt.Println(res5) // >>> true res6, err := rdb.SIsMember(ctx, "bikes:racing:usa", "bike:2").Result() - if err != nil { panic(err) } @@ -136,20 +128,17 @@ func ExampleClient_sinter() { // REMOVE_END _, err := rdb.SAdd(ctx, "bikes:racing:france", "bike:1", "bike:2", "bike:3").Result() - if err != nil { panic(err) } _, err = rdb.SAdd(ctx, "bikes:racing:usa", "bike:1", "bike:4").Result() - if err != nil { panic(err) } // STEP_START sinter res7, err := rdb.SInter(ctx, "bikes:racing:france", "bikes:racing:usa").Result() - if err != nil { panic(err) } @@ -177,14 +166,12 @@ func ExampleClient_scard() { // REMOVE_END _, err := rdb.SAdd(ctx, "bikes:racing:france", "bike:1", "bike:2", "bike:3").Result() - if err != nil { panic(err) } // STEP_START scard res8, err := rdb.SCard(ctx, "bikes:racing:france").Result() - if err != nil { panic(err) } @@ -213,7 +200,6 @@ func ExampleClient_saddsmembers() { // STEP_START sadd_smembers res9, err := rdb.SAdd(ctx, "bikes:racing:france", "bike:1", "bike:2", "bike:3").Result() - if err != nil { panic(err) } @@ -221,7 +207,6 @@ func ExampleClient_saddsmembers() { fmt.Println(res9) // >>> 3 res10, err := rdb.SMembers(ctx, "bikes:racing:france").Result() - if err != nil { panic(err) } @@ -253,14 +238,12 @@ func ExampleClient_smismember() { // REMOVE_END _, err := rdb.SAdd(ctx, "bikes:racing:france", "bike:1", "bike:2", "bike:3").Result() - if err != nil { panic(err) } // STEP_START smismember res11, err := rdb.SIsMember(ctx, "bikes:racing:france", "bike:1").Result() - if err != nil { panic(err) } @@ -268,7 +251,6 @@ func ExampleClient_smismember() { fmt.Println(res11) // >>> true res12, err := rdb.SMIsMember(ctx, "bikes:racing:france", "bike:2", "bike:3", "bike:4").Result() - if err != nil { panic(err) } @@ -299,7 +281,6 @@ func ExampleClient_sdiff() { // STEP_START sdiff _, err := rdb.SAdd(ctx, "bikes:racing:france", "bike:1", "bike:2", "bike:3").Result() - if err != nil { panic(err) } @@ -307,7 +288,6 @@ func ExampleClient_sdiff() { _, err = rdb.SAdd(ctx, "bikes:racing:usa", "bike:1", "bike:4").Result() res13, err := rdb.SDiff(ctx, "bikes:racing:france", "bikes:racing:usa").Result() - if err != nil { panic(err) } @@ -341,25 +321,21 @@ func ExampleClient_multisets() { // STEP_START multisets _, err := rdb.SAdd(ctx, "bikes:racing:france", "bike:1", "bike:2", "bike:3").Result() - if err != nil { panic(err) } _, err = rdb.SAdd(ctx, "bikes:racing:usa", "bike:1", "bike:4").Result() - if err != nil { panic(err) } _, err = rdb.SAdd(ctx, "bikes:racing:italy", "bike:1", "bike:2", "bike:3", "bike:4").Result() - if err != nil { panic(err) } res14, err := rdb.SInter(ctx, "bikes:racing:france", "bikes:racing:usa", "bikes:racing:italy").Result() - if err != nil { panic(err) } @@ -367,7 +343,6 @@ func ExampleClient_multisets() { fmt.Println(res14) // >>> [bike:1] res15, err := rdb.SUnion(ctx, "bikes:racing:france", "bikes:racing:usa", "bikes:racing:italy").Result() - if err != nil { panic(err) } @@ -378,7 +353,6 @@ func ExampleClient_multisets() { fmt.Println(res15) // >>> [bike:1 bike:2 bike:3 bike:4] res16, err := rdb.SDiff(ctx, "bikes:racing:france", "bikes:racing:usa", "bikes:racing:italy").Result() - if err != nil { panic(err) } @@ -386,7 +360,6 @@ func ExampleClient_multisets() { fmt.Println(res16) // >>> [] res17, err := rdb.SDiff(ctx, "bikes:racing:usa", "bikes:racing:france").Result() - if err != nil { panic(err) } @@ -394,7 +367,6 @@ func ExampleClient_multisets() { fmt.Println(res17) // >>> [bike:4] res18, err := rdb.SDiff(ctx, "bikes:racing:france", "bikes:racing:usa").Result() - if err != nil { panic(err) } @@ -430,13 +402,11 @@ func ExampleClient_srem() { // STEP_START srem _, err := rdb.SAdd(ctx, "bikes:racing:france", "bike:1", "bike:2", "bike:3", "bike:4", "bike:5").Result() - if err != nil { panic(err) } res19, err := rdb.SRem(ctx, "bikes:racing:france", "bike:1").Result() - if err != nil { panic(err) } @@ -444,7 +414,6 @@ func ExampleClient_srem() { fmt.Println(res19) // >>> 1 res20, err := rdb.SPop(ctx, "bikes:racing:france").Result() - if err != nil { panic(err) } @@ -452,7 +421,6 @@ func ExampleClient_srem() { fmt.Println(res20) // >>> res21, err := rdb.SMembers(ctx, "bikes:racing:france").Result() - if err != nil { panic(err) } @@ -460,7 +428,6 @@ func ExampleClient_srem() { fmt.Println(res21) // >>> res22, err := rdb.SRandMember(ctx, "bikes:racing:france").Result() - if err != nil { panic(err) } diff --git a/doctests/ss_tutorial_test.go b/doctests/ss_tutorial_test.go index 35687e7e9..601fbaeb1 100644 --- a/doctests/ss_tutorial_test.go +++ b/doctests/ss_tutorial_test.go @@ -29,7 +29,6 @@ func ExampleClient_zadd() { res1, err := rdb.ZAdd(ctx, "racer_scores", redis.Z{Member: "Norem", Score: 10}, ).Result() - if err != nil { panic(err) } @@ -39,7 +38,6 @@ func ExampleClient_zadd() { res2, err := rdb.ZAdd(ctx, "racer_scores", redis.Z{Member: "Castilla", Score: 12}, ).Result() - if err != nil { panic(err) } @@ -54,7 +52,6 @@ func ExampleClient_zadd() { redis.Z{Member: "Prickett", Score: 14}, redis.Z{Member: "Castilla", Score: 12}, ).Result() - if err != nil { panic(err) } @@ -91,14 +88,12 @@ func ExampleClient_zrange() { redis.Z{Member: "Prickett", Score: 14}, redis.Z{Member: "Castilla", Score: 12}, ).Result() - if err != nil { panic(err) } // STEP_START zrange res4, err := rdb.ZRange(ctx, "racer_scores", 0, -1).Result() - if err != nil { panic(err) } @@ -107,7 +102,6 @@ func ExampleClient_zrange() { // >>> [Ford Sam-Bodden Norem Royce Castilla Prickett] res5, err := rdb.ZRevRange(ctx, "racer_scores", 0, -1).Result() - if err != nil { panic(err) } @@ -144,14 +138,12 @@ func ExampleClient_zrangewithscores() { redis.Z{Member: "Prickett", Score: 14}, redis.Z{Member: "Castilla", Score: 12}, ).Result() - if err != nil { panic(err) } // STEP_START zrange_withscores res6, err := rdb.ZRangeWithScores(ctx, "racer_scores", 0, -1).Result() - if err != nil { panic(err) } @@ -187,7 +179,6 @@ func ExampleClient_zrangebyscore() { redis.Z{Member: "Prickett", Score: 14}, redis.Z{Member: "Castilla", Score: 12}, ).Result() - if err != nil { panic(err) } @@ -196,7 +187,6 @@ func ExampleClient_zrangebyscore() { res7, err := rdb.ZRangeByScore(ctx, "racer_scores", &redis.ZRangeBy{Min: "-inf", Max: "10"}, ).Result() - if err != nil { panic(err) } @@ -232,14 +222,12 @@ func ExampleClient_zremrangebyscore() { redis.Z{Member: "Prickett", Score: 14}, redis.Z{Member: "Castilla", Score: 12}, ).Result() - if err != nil { panic(err) } // STEP_START zremrangebyscore res8, err := rdb.ZRem(ctx, "racer_scores", "Castilla").Result() - if err != nil { panic(err) } @@ -247,7 +235,6 @@ func ExampleClient_zremrangebyscore() { fmt.Println(res8) // >>> 1 res9, err := rdb.ZRemRangeByScore(ctx, "racer_scores", "-inf", "9").Result() - if err != nil { panic(err) } @@ -255,7 +242,6 @@ func ExampleClient_zremrangebyscore() { fmt.Println(res9) // >>> 2 res10, err := rdb.ZRange(ctx, "racer_scores", 0, -1).Result() - if err != nil { panic(err) } @@ -290,14 +276,12 @@ func ExampleClient_zrank() { redis.Z{Member: "Royce", Score: 10}, redis.Z{Member: "Prickett", Score: 14}, ).Result() - if err != nil { panic(err) } // STEP_START zrank res11, err := rdb.ZRank(ctx, "racer_scores", "Norem").Result() - if err != nil { panic(err) } @@ -305,7 +289,6 @@ func ExampleClient_zrank() { fmt.Println(res11) // >>> 0 res12, err := rdb.ZRevRank(ctx, "racer_scores", "Norem").Result() - if err != nil { panic(err) } @@ -348,7 +331,6 @@ func ExampleClient_zaddlex() { redis.Z{Member: "Prickett", Score: 0}, redis.Z{Member: "Castilla", Score: 0}, ).Result() - if err != nil { panic(err) } @@ -356,7 +338,6 @@ func ExampleClient_zaddlex() { fmt.Println(res13) // >>> 3 res14, err := rdb.ZRange(ctx, "racer_scores", 0, -1).Result() - if err != nil { panic(err) } @@ -367,7 +348,6 @@ func ExampleClient_zaddlex() { res15, err := rdb.ZRangeByLex(ctx, "racer_scores", &redis.ZRangeBy{ Min: "[A", Max: "[L", }).Result() - if err != nil { panic(err) } @@ -400,7 +380,6 @@ func ExampleClient_leaderboard() { res16, err := rdb.ZAdd(ctx, "racer_scores", redis.Z{Member: "Wood", Score: 100}, ).Result() - if err != nil { panic(err) } @@ -410,7 +389,6 @@ func ExampleClient_leaderboard() { res17, err := rdb.ZAdd(ctx, "racer_scores", redis.Z{Member: "Henshaw", Score: 100}, ).Result() - if err != nil { panic(err) } @@ -420,7 +398,6 @@ func ExampleClient_leaderboard() { res18, err := rdb.ZAdd(ctx, "racer_scores", redis.Z{Member: "Henshaw", Score: 150}, ).Result() - if err != nil { panic(err) } @@ -428,7 +405,6 @@ func ExampleClient_leaderboard() { fmt.Println(res18) // >>> 0 res19, err := rdb.ZIncrBy(ctx, "racer_scores", 50, "Wood").Result() - if err != nil { panic(err) } @@ -436,7 +412,6 @@ func ExampleClient_leaderboard() { fmt.Println(res19) // >>> 150 res20, err := rdb.ZIncrBy(ctx, "racer_scores", 50, "Henshaw").Result() - if err != nil { panic(err) } diff --git a/doctests/stream_tutorial_test.go b/doctests/stream_tutorial_test.go index e39919ea6..30e7d5099 100644 --- a/doctests/stream_tutorial_test.go +++ b/doctests/stream_tutorial_test.go @@ -41,7 +41,6 @@ func ExampleClient_xadd() { "location_id": 1, }, }).Result() - if err != nil { panic(err) } @@ -57,7 +56,6 @@ func ExampleClient_xadd() { "location_id": 1, }, }).Result() - if err != nil { panic(err) } @@ -73,7 +71,6 @@ func ExampleClient_xadd() { "location_id": 1, }, }).Result() - if err != nil { panic(err) } @@ -86,7 +83,6 @@ func ExampleClient_xadd() { // REMOVE_END xlen, err := rdb.XLen(ctx, "race:france").Result() - if err != nil { panic(err) } @@ -122,7 +118,6 @@ func ExampleClient_racefrance1() { }, ID: "1692632086370-0", }).Result() - if err != nil { panic(err) } @@ -137,7 +132,6 @@ func ExampleClient_racefrance1() { }, ID: "1692632094485-0", }).Result() - if err != nil { panic(err) } @@ -152,14 +146,12 @@ func ExampleClient_racefrance1() { }, ID: "1692632102976-0", }).Result() - if err != nil { panic(err) } // STEP_START xrange res4, err := rdb.XRangeN(ctx, "race:france", "1691765278160-0", "+", 2).Result() - if err != nil { panic(err) } @@ -174,7 +166,6 @@ func ExampleClient_racefrance1() { Count: 100, Block: 300, }).Result() - if err != nil { panic(err) } @@ -193,17 +184,15 @@ func ExampleClient_racefrance1() { "location_id": 2, }, }).Result() - if err != nil { panic(err) } - //fmt.Println(res6) // >>> 1692632147973-0 + // fmt.Println(res6) // >>> 1692632147973-0 // STEP_END // STEP_START xlen res7, err := rdb.XLen(ctx, "race:france").Result() - if err != nil { panic(err) } @@ -244,7 +233,6 @@ func ExampleClient_raceusa() { }, ID: "0-1", }).Result() - if err != nil { panic(err) } @@ -258,7 +246,6 @@ func ExampleClient_raceusa() { }, ID: "0-2", }).Result() - if err != nil { panic(err) } @@ -273,7 +260,6 @@ func ExampleClient_raceusa() { }, ID: "0-1", }).Result() - if err != nil { // fmt.Println(err) // >>> ERR The ID specified in XADD is equal or smaller than the target stream top item @@ -288,7 +274,6 @@ func ExampleClient_raceusa() { }, ID: "0-*", }).Result() - if err != nil { panic(err) } @@ -331,7 +316,6 @@ func ExampleClient_racefrance2() { }, ID: "1692632086370-0", }).Result() - if err != nil { panic(err) } @@ -346,7 +330,6 @@ func ExampleClient_racefrance2() { }, ID: "1692632094485-0", }).Result() - if err != nil { panic(err) } @@ -361,7 +344,6 @@ func ExampleClient_racefrance2() { }, ID: "1692632102976-0", }).Result() - if err != nil { panic(err) } @@ -376,13 +358,11 @@ func ExampleClient_racefrance2() { }, ID: "1692632147973-0", }).Result() - if err != nil { panic(err) } // STEP_START xrange_all res12, err := rdb.XRange(ctx, "race:france", "-", "+").Result() - if err != nil { panic(err) } @@ -395,7 +375,6 @@ func ExampleClient_racefrance2() { res13, err := rdb.XRange(ctx, "race:france", "1692632086369", "1692632086371", ).Result() - if err != nil { panic(err) } @@ -406,7 +385,6 @@ func ExampleClient_racefrance2() { // STEP_START xrange_step_1 res14, err := rdb.XRangeN(ctx, "race:france", "-", "+", 2).Result() - if err != nil { panic(err) } @@ -419,7 +397,6 @@ func ExampleClient_racefrance2() { res15, err := rdb.XRangeN(ctx, "race:france", "(1692632094485-0", "+", 2, ).Result() - if err != nil { panic(err) } @@ -432,7 +409,6 @@ func ExampleClient_racefrance2() { res16, err := rdb.XRangeN(ctx, "race:france", "(1692632147973-0", "+", 2, ).Result() - if err != nil { panic(err) } @@ -443,7 +419,6 @@ func ExampleClient_racefrance2() { // STEP_START xrevrange res17, err := rdb.XRevRangeN(ctx, "race:france", "+", "-", 1).Result() - if err != nil { panic(err) } @@ -457,7 +432,6 @@ func ExampleClient_racefrance2() { Streams: []string{"race:france", "0"}, Count: 2, }).Result() - if err != nil { panic(err) } @@ -501,14 +475,12 @@ func ExampleClient_xgroupcreate() { }, ID: "1692632086370-0", }).Result() - if err != nil { panic(err) } // STEP_START xgroup_create res19, err := rdb.XGroupCreate(ctx, "race:france", "france_riders", "$").Result() - if err != nil { panic(err) } @@ -539,7 +511,6 @@ func ExampleClient_xgroupcreatemkstream() { res20, err := rdb.XGroupCreateMkStream(ctx, "race:italy", "italy_riders", "$", ).Result() - if err != nil { panic(err) } @@ -569,7 +540,6 @@ func ExampleClient_xgroupread() { _, err := rdb.XGroupCreateMkStream(ctx, "race:italy", "italy_riders", "$", ).Result() - if err != nil { panic(err) } @@ -580,7 +550,6 @@ func ExampleClient_xgroupread() { Values: map[string]interface{}{"rider": "Castilla"}, }).Result() // >>> 1692632639151-0 - if err != nil { panic(err) } @@ -590,7 +559,6 @@ func ExampleClient_xgroupread() { Values: map[string]interface{}{"rider": "Royce"}, }).Result() // >>> 1692632647899-0 - if err != nil { panic(err) } @@ -600,7 +568,6 @@ func ExampleClient_xgroupread() { Values: map[string]interface{}{"rider": "Sam-Bodden"}, }).Result() // >>> 1692632662819-0 - if err != nil { panic(err) } @@ -610,7 +577,6 @@ func ExampleClient_xgroupread() { Values: map[string]interface{}{"rider": "Prickett"}, }).Result() // >>> 1692632670501-0 - if err != nil { panic(err) } @@ -620,7 +586,6 @@ func ExampleClient_xgroupread() { Values: map[string]interface{}{"rider": "Norem"}, }).Result() // >>> 1692632678249-0 - if err != nil { panic(err) } @@ -633,7 +598,6 @@ func ExampleClient_xgroupread() { Consumer: "Alice", Count: 1, }).Result() - if err != nil { panic(err) } @@ -647,7 +611,6 @@ func ExampleClient_xgroupread() { // REMOVE_END xlen, err := rdb.XLen(ctx, "race:italy").Result() - if err != nil { panic(err) } @@ -677,7 +640,6 @@ func ExampleClient_raceitaly() { _, err := rdb.XGroupCreateMkStream(ctx, "race:italy", "italy_riders", "$", ).Result() - if err != nil { panic(err) } @@ -687,7 +649,6 @@ func ExampleClient_raceitaly() { Values: map[string]interface{}{"rider": "Castilla"}, ID: "1692632639151-0", }).Result() - if err != nil { panic(err) } @@ -697,7 +658,6 @@ func ExampleClient_raceitaly() { Values: map[string]interface{}{"rider": "Royce"}, ID: "1692632647899-0", }).Result() - if err != nil { panic(err) } @@ -707,7 +667,6 @@ func ExampleClient_raceitaly() { Values: map[string]interface{}{"rider": "Sam-Bodden"}, ID: "1692632662819-0", }).Result() - if err != nil { panic(err) } @@ -717,7 +676,6 @@ func ExampleClient_raceitaly() { Values: map[string]interface{}{"rider": "Prickett"}, ID: "1692632670501-0", }).Result() - if err != nil { panic(err) } @@ -727,7 +685,6 @@ func ExampleClient_raceitaly() { Values: map[string]interface{}{"rider": "Norem"}, ID: "1692632678249-0", }).Result() - if err != nil { panic(err) } @@ -738,7 +695,6 @@ func ExampleClient_raceitaly() { Consumer: "Alice", Count: 1, }).Result() - if err != nil { panic(err) } @@ -748,7 +704,6 @@ func ExampleClient_raceitaly() { Group: "italy_riders", Consumer: "Alice", }).Result() - if err != nil { panic(err) } @@ -761,7 +716,6 @@ func ExampleClient_raceitaly() { res23, err := rdb.XAck(ctx, "race:italy", "italy_riders", "1692632639151-0", ).Result() - if err != nil { panic(err) } @@ -773,7 +727,6 @@ func ExampleClient_raceitaly() { Group: "italy_riders", Consumer: "Alice", }).Result() - if err != nil { panic(err) } @@ -789,7 +742,6 @@ func ExampleClient_raceitaly() { Consumer: "Bob", Count: 2, }).Result() - if err != nil { panic(err) } @@ -801,7 +753,6 @@ func ExampleClient_raceitaly() { // STEP_START xpending res26, err := rdb.XPending(ctx, "race:italy", "italy_riders").Result() - if err != nil { panic(err) } @@ -818,7 +769,6 @@ func ExampleClient_raceitaly() { End: "+", Count: 10, }).Result() - if err != nil { panic(err) } @@ -831,7 +781,6 @@ func ExampleClient_raceitaly() { res28, err := rdb.XRange(ctx, "race:italy", "1692632647899-0", "1692632647899-0", ).Result() - if err != nil { panic(err) } @@ -847,7 +796,6 @@ func ExampleClient_raceitaly() { MinIdle: 0, Messages: []string{"1692632647899-0"}, }).Result() - if err != nil { panic(err) } @@ -863,7 +811,6 @@ func ExampleClient_raceitaly() { Start: "0-0", Count: 1, }).Result() - if err != nil { panic(err) } @@ -880,7 +827,6 @@ func ExampleClient_raceitaly() { Start: "(1692632662819-0", Count: 1, }).Result() - if err != nil { panic(err) } @@ -891,7 +837,6 @@ func ExampleClient_raceitaly() { // STEP_START xinfo res32, err := rdb.XInfoStream(ctx, "race:italy").Result() - if err != nil { panic(err) } @@ -902,7 +847,6 @@ func ExampleClient_raceitaly() { // STEP_START xinfo_groups res33, err := rdb.XInfoGroups(ctx, "race:italy").Result() - if err != nil { panic(err) } @@ -913,7 +857,6 @@ func ExampleClient_raceitaly() { // STEP_START xinfo_consumers res34, err := rdb.XInfoConsumers(ctx, "race:italy", "italy_riders").Result() - if err != nil { panic(err) } @@ -929,7 +872,6 @@ func ExampleClient_raceitaly() { Values: map[string]interface{}{"rider": "Jones"}, }, ).Result() - if err != nil { panic(err) } @@ -940,7 +882,6 @@ func ExampleClient_raceitaly() { Values: map[string]interface{}{"rider": "Wood"}, }, ).Result() - if err != nil { panic(err) } @@ -951,13 +892,11 @@ func ExampleClient_raceitaly() { Values: map[string]interface{}{"rider": "Henshaw"}, }, ).Result() - if err != nil { panic(err) } res35, err := rdb.XLen(ctx, "race:italy").Result() - if err != nil { panic(err) } @@ -965,7 +904,6 @@ func ExampleClient_raceitaly() { fmt.Println(res35) // >>> 2 res36, err := rdb.XRange(ctx, "race:italy", "-", "+").Result() - if err != nil { panic(err) } @@ -976,7 +914,6 @@ func ExampleClient_raceitaly() { // STEP_START xtrim res37, err := rdb.XTrimMaxLen(ctx, "race:italy", 10).Result() - if err != nil { panic(err) } @@ -986,7 +923,6 @@ func ExampleClient_raceitaly() { // STEP_START xtrim2 res38, err := rdb.XTrimMaxLenApprox(ctx, "race:italy", 10, 20).Result() - if err != nil { panic(err) } @@ -1039,7 +975,6 @@ func ExampleClient_xdel() { ID: "1692633198206-0", }, ).Result() - if err != nil { panic(err) } @@ -1051,14 +986,12 @@ func ExampleClient_xdel() { ID: "1692633208557-0", }, ).Result() - if err != nil { panic(err) } // STEP_START xdel res39, err := rdb.XRangeN(ctx, "race:italy", "-", "+", 2).Result() - if err != nil { panic(err) } @@ -1067,7 +1000,6 @@ func ExampleClient_xdel() { // >>> [{1692633198206-0 map[rider:Wood]} {1692633208557-0 map[rider:Henshaw]}] res40, err := rdb.XDel(ctx, "race:italy", "1692633208557-0").Result() - if err != nil { panic(err) } @@ -1075,7 +1007,6 @@ func ExampleClient_xdel() { fmt.Println(res40) // 1 res41, err := rdb.XRangeN(ctx, "race:italy", "-", "+", 2).Result() - if err != nil { panic(err) } diff --git a/doctests/string_example_test.go b/doctests/string_example_test.go index 025659fe8..ae4603688 100644 --- a/doctests/string_example_test.go +++ b/doctests/string_example_test.go @@ -27,7 +27,6 @@ func ExampleClient_set_get() { // STEP_START set_get res1, err := rdb.Set(ctx, "bike:1", "Deimos", 0).Result() - if err != nil { panic(err) } @@ -35,7 +34,6 @@ func ExampleClient_set_get() { fmt.Println(res1) // >>> OK res2, err := rdb.Get(ctx, "bike:1").Result() - if err != nil { panic(err) } @@ -65,7 +63,6 @@ func ExampleClient_setnx_xx() { // STEP_START setnx_xx res3, err := rdb.SetNX(ctx, "bike:1", "bike", 0).Result() - if err != nil { panic(err) } @@ -73,7 +70,6 @@ func ExampleClient_setnx_xx() { fmt.Println(res3) // >>> false res4, err := rdb.Get(ctx, "bike:1").Result() - if err != nil { panic(err) } @@ -81,7 +77,6 @@ func ExampleClient_setnx_xx() { fmt.Println(res4) // >>> Deimos res5, err := rdb.SetXX(ctx, "bike:1", "bike", 0).Result() - if err != nil { panic(err) } @@ -112,7 +107,6 @@ func ExampleClient_mset() { // STEP_START mset res6, err := rdb.MSet(ctx, "bike:1", "Deimos", "bike:2", "Ares", "bike:3", "Vanth").Result() - if err != nil { panic(err) } @@ -120,7 +114,6 @@ func ExampleClient_mset() { fmt.Println(res6) // >>> OK res7, err := rdb.MGet(ctx, "bike:1", "bike:2", "bike:3").Result() - if err != nil { panic(err) } @@ -150,7 +143,6 @@ func ExampleClient_incr() { // STEP_START incr res8, err := rdb.Set(ctx, "total_crashes", "0", 0).Result() - if err != nil { panic(err) } @@ -158,7 +150,6 @@ func ExampleClient_incr() { fmt.Println(res8) // >>> OK res9, err := rdb.Incr(ctx, "total_crashes").Result() - if err != nil { panic(err) } @@ -166,7 +157,6 @@ func ExampleClient_incr() { fmt.Println(res9) // >>> 1 res10, err := rdb.IncrBy(ctx, "total_crashes", 10).Result() - if err != nil { panic(err) } diff --git a/doctests/tdigest_tutorial_test.go b/doctests/tdigest_tutorial_test.go index 9cda4c373..f16af97a6 100644 --- a/doctests/tdigest_tutorial_test.go +++ b/doctests/tdigest_tutorial_test.go @@ -28,7 +28,6 @@ func ExampleClient_tdigstart() { // STEP_START tdig_start res1, err := rdb.TDigestCreate(ctx, "bikes:sales").Result() - if err != nil { panic(err) } @@ -36,7 +35,6 @@ func ExampleClient_tdigstart() { fmt.Println(res1) // >>> OK res2, err := rdb.TDigestAdd(ctx, "bikes:sales", 21).Result() - if err != nil { panic(err) } @@ -46,7 +44,6 @@ func ExampleClient_tdigstart() { res3, err := rdb.TDigestAdd(ctx, "bikes:sales", 150, 95, 75, 34, ).Result() - if err != nil { panic(err) } @@ -78,7 +75,6 @@ func ExampleClient_tdigcdf() { // STEP_START tdig_cdf res4, err := rdb.TDigestCreate(ctx, "racer_ages").Result() - if err != nil { panic(err) } @@ -89,7 +85,6 @@ func ExampleClient_tdigcdf() { 45.88, 44.2, 58.03, 19.76, 39.84, 69.28, 50.97, 25.41, 19.27, 85.71, 42.63, ).Result() - if err != nil { panic(err) } @@ -97,7 +92,6 @@ func ExampleClient_tdigcdf() { fmt.Println(res5) // >>> OK res6, err := rdb.TDigestRank(ctx, "racer_ages", 50).Result() - if err != nil { panic(err) } @@ -105,7 +99,6 @@ func ExampleClient_tdigcdf() { fmt.Println(res6) // >>> [7] res7, err := rdb.TDigestRank(ctx, "racer_ages", 50, 40).Result() - if err != nil { panic(err) } @@ -136,7 +129,6 @@ func ExampleClient_tdigquant() { // REMOVE_END _, err := rdb.TDigestCreate(ctx, "racer_ages").Result() - if err != nil { panic(err) } @@ -145,14 +137,12 @@ func ExampleClient_tdigquant() { 45.88, 44.2, 58.03, 19.76, 39.84, 69.28, 50.97, 25.41, 19.27, 85.71, 42.63, ).Result() - if err != nil { panic(err) } // STEP_START tdig_quant res8, err := rdb.TDigestQuantile(ctx, "racer_ages", 0.5).Result() - if err != nil { panic(err) } @@ -160,7 +150,6 @@ func ExampleClient_tdigquant() { fmt.Println(res8) // >>> [44.2] res9, err := rdb.TDigestByRank(ctx, "racer_ages", 4).Result() - if err != nil { panic(err) } @@ -189,7 +178,6 @@ func ExampleClient_tdigmin() { // REMOVE_END _, err := rdb.TDigestCreate(ctx, "racer_ages").Result() - if err != nil { panic(err) } @@ -198,14 +186,12 @@ func ExampleClient_tdigmin() { 45.88, 44.2, 58.03, 19.76, 39.84, 69.28, 50.97, 25.41, 19.27, 85.71, 42.63, ).Result() - if err != nil { panic(err) } // STEP_START tdig_min res10, err := rdb.TDigestMin(ctx, "racer_ages").Result() - if err != nil { panic(err) } @@ -213,7 +199,6 @@ func ExampleClient_tdigmin() { fmt.Println(res10) // >>> 19.27 res11, err := rdb.TDigestMax(ctx, "racer_ages").Result() - if err != nil { panic(err) } @@ -241,14 +226,12 @@ func ExampleClient_tdigreset() { rdb.Del(ctx, "racer_ages") // REMOVE_END _, err := rdb.TDigestCreate(ctx, "racer_ages").Result() - if err != nil { panic(err) } // STEP_START tdig_reset res12, err := rdb.TDigestReset(ctx, "racer_ages").Result() - if err != nil { panic(err) } diff --git a/doctests/topk_tutorial_test.go b/doctests/topk_tutorial_test.go index db3362059..2e487ab67 100644 --- a/doctests/topk_tutorial_test.go +++ b/doctests/topk_tutorial_test.go @@ -28,7 +28,6 @@ func ExampleClient_topk() { // STEP_START topk res1, err := rdb.TopKReserve(ctx, "bikes:keywords", 5).Result() - if err != nil { panic(err) } @@ -45,7 +44,6 @@ func ExampleClient_topk() { "store", "seat", ).Result() - if err != nil { panic(err) } @@ -53,7 +51,6 @@ func ExampleClient_topk() { fmt.Println(res2) // >>> [ handlebars ] res3, err := rdb.TopKList(ctx, "bikes:keywords").Result() - if err != nil { panic(err) } @@ -61,7 +58,6 @@ func ExampleClient_topk() { fmt.Println(res3) // [store seat pedals tires handles] res4, err := rdb.TopKQuery(ctx, "bikes:keywords", "store", "handlebars").Result() - if err != nil { panic(err) } diff --git a/error.go b/error.go index 6f47f7cf2..65922b2b7 100644 --- a/error.go +++ b/error.go @@ -126,7 +126,7 @@ func isBadConn(err error, allowTimeout bool, addr string) bool { return true } -func isMovedError(err error) (moved bool, ask bool, addr string) { +func isMovedError(err error) (moved, ask bool, addr string) { if !isRedisError(err) { return } diff --git a/error_test.go b/error_test.go index da9a471a2..5e3b64738 100644 --- a/error_test.go +++ b/error_test.go @@ -7,6 +7,7 @@ import ( . "github.com/bsm/ginkgo/v2" . "github.com/bsm/gomega" + "github.com/redis/go-redis/v9" ) @@ -24,11 +25,9 @@ func (t testTimeout) Error() string { var _ = Describe("error", func() { BeforeEach(func() { - }) AfterEach(func() { - }) It("should retry", func() { diff --git a/example/hset-struct/main.go b/example/hset-struct/main.go index 2e08f542f..21c65abfe 100644 --- a/example/hset-struct/main.go +++ b/example/hset-struct/main.go @@ -37,7 +37,7 @@ func main() { _ = rdb.FlushDB(ctx).Err() - t := time.Date(2025, 02, 8, 0, 0, 0, 0, time.UTC) + t := time.Date(2025, 0o2, 8, 0, 0, 0, 0, time.UTC) data := Model{ Str1: "hello", diff --git a/extra/rediscmd/rediscmd.go b/extra/rediscmd/rediscmd.go index 6423b6abd..3969c7163 100644 --- a/extra/rediscmd/rediscmd.go +++ b/extra/rediscmd/rediscmd.go @@ -105,7 +105,7 @@ func appendArg(b []byte, v interface{}) []byte { } } -func appendUTF8String(dst []byte, src []byte) []byte { +func appendUTF8String(dst, src []byte) []byte { if isSimple(src) { dst = append(dst, src...) return dst diff --git a/extra/rediscmd/rediscmd_test.go b/extra/rediscmd/rediscmd_test.go index 2219ab0f2..9768aed8a 100644 --- a/extra/rediscmd/rediscmd_test.go +++ b/extra/rediscmd/rediscmd_test.go @@ -14,7 +14,7 @@ func TestGinkgo(t *testing.T) { var _ = Describe("AppendArg", func() { DescribeTable("...", - func(src string, wanted string) { + func(src, wanted string) { b := appendArg(nil, src) Expect(string(b)).To(Equal(wanted)) }, diff --git a/generic_commands.go b/generic_commands.go index dc6c3fe01..8f0bcd9a5 100644 --- a/generic_commands.go +++ b/generic_commands.go @@ -40,7 +40,7 @@ type GenericCmdable interface { Touch(ctx context.Context, keys ...string) *IntCmd TTL(ctx context.Context, key string) *DurationCmd Type(ctx context.Context, key string) *StatusCmd - Copy(ctx context.Context, sourceKey string, destKey string, db int, replace bool) *IntCmd + Copy(ctx context.Context, sourceKey, destKey string, db int, replace bool) *IntCmd Scan(ctx context.Context, cursor uint64, match string, count int64) *ScanCmd ScanType(ctx context.Context, cursor uint64, match string, count int64, keyType string) *ScanCmd diff --git a/geo_commands.go b/geo_commands.go index f047b98aa..85363ce0e 100644 --- a/geo_commands.go +++ b/geo_commands.go @@ -15,7 +15,7 @@ type GeoCmdable interface { GeoSearch(ctx context.Context, key string, q *GeoSearchQuery) *StringSliceCmd GeoSearchLocation(ctx context.Context, key string, q *GeoSearchLocationQuery) *GeoSearchLocationCmd GeoSearchStore(ctx context.Context, key, store string, q *GeoSearchStoreQuery) *IntCmd - GeoDist(ctx context.Context, key string, member1, member2, unit string) *FloatCmd + GeoDist(ctx context.Context, key, member1, member2, unit string) *FloatCmd GeoHash(ctx context.Context, key string, members ...string) *StringSliceCmd } @@ -120,7 +120,7 @@ func (c cmdable) GeoSearchStore(ctx context.Context, key, store string, q *GeoSe } func (c cmdable) GeoDist( - ctx context.Context, key string, member1, member2, unit string, + ctx context.Context, key, member1, member2, unit string, ) *FloatCmd { if unit == "" { unit = "km" diff --git a/hash_commands.go b/hash_commands.go index 98a361b3e..3550596b7 100644 --- a/hash_commands.go +++ b/hash_commands.go @@ -201,6 +201,7 @@ func (c cmdable) HStrLen(ctx context.Context, key, field string) *IntCmd { _ = c(ctx, cmd) return cmd } + func (c cmdable) HScanNoValues(ctx context.Context, key string, cursor uint64, match string, count int64) *ScanCmd { args := []interface{}{"hscan", key, cursor} if match != "" { @@ -329,7 +330,6 @@ func (c cmdable) HPExpireWithArgs(ctx context.Context, key string, expiration ti // // [HExpireAt Documentation]: https://redis.io/commands/hexpireat/ func (c cmdable) HExpireAt(ctx context.Context, key string, tm time.Time, fields ...string) *IntSliceCmd { - args := []interface{}{"HEXPIREAT", key, tm.Unix(), "FIELDS", len(fields)} for _, field := range fields { diff --git a/internal/arg.go b/internal/arg.go index 2e5ca33de..3011ea390 100644 --- a/internal/arg.go +++ b/internal/arg.go @@ -52,7 +52,7 @@ func AppendArg(b []byte, v interface{}) []byte { } } -func appendUTF8String(dst []byte, src []byte) []byte { +func appendUTF8String(dst, src []byte) []byte { dst = append(dst, src...) return dst } diff --git a/internal/hscan/hscan.go b/internal/hscan/hscan.go index 203ec4aa8..dd5e658c9 100644 --- a/internal/hscan/hscan.go +++ b/internal/hscan/hscan.go @@ -73,7 +73,7 @@ func Struct(dst interface{}) (StructValue, error) { // Scan scans the results from a key-value Redis map result set to a destination struct. // The Redis keys are matched to the struct's field with the `redis` tag. -func Scan(dst interface{}, keys []interface{}, vals []interface{}) error { +func Scan(dst interface{}, keys, vals []interface{}) error { if len(keys) != len(vals) { return errors.New("args should have the same number of keys and vals") } diff --git a/internal/hscan/structmap.go b/internal/hscan/structmap.go index 1a560e4a3..5031961d7 100644 --- a/internal/hscan/structmap.go +++ b/internal/hscan/structmap.go @@ -86,7 +86,7 @@ type StructValue struct { value reflect.Value } -func (s StructValue) Scan(key string, value string) error { +func (s StructValue) Scan(key, value string) error { field, ok := s.spec.m[key] if !ok { return nil diff --git a/internal/proto/writer_test.go b/internal/proto/writer_test.go index 1d5152dc0..f858b3421 100644 --- a/internal/proto/writer_test.go +++ b/internal/proto/writer_test.go @@ -111,7 +111,7 @@ var _ = Describe("WriteArg", func() { wr = proto.NewWriter(buf) }) - t := time.Date(2025, 2, 8, 00, 00, 00, 0, time.UTC) + t := time.Date(2025, 2, 8, 0o0, 0o0, 0o0, 0, time.UTC) args := map[any]string{ "hello": "$5\r\nhello\r\n", diff --git a/internal/util/strconv.go b/internal/util/strconv.go index db5033802..cba1cfc99 100644 --- a/internal/util/strconv.go +++ b/internal/util/strconv.go @@ -6,11 +6,11 @@ func Atoi(b []byte) (int, error) { return strconv.Atoi(BytesToString(b)) } -func ParseInt(b []byte, base int, bitSize int) (int64, error) { +func ParseInt(b []byte, base, bitSize int) (int64, error) { return strconv.ParseInt(BytesToString(b), base, bitSize) } -func ParseUint(b []byte, base int, bitSize int) (uint64, error) { +func ParseUint(b []byte, base, bitSize int) (uint64, error) { return strconv.ParseUint(BytesToString(b), base, bitSize) } diff --git a/iterator_test.go b/iterator_test.go index c4f046476..14cba2246 100644 --- a/iterator_test.go +++ b/iterator_test.go @@ -21,7 +21,7 @@ var _ = Describe("ScanIterator", func() { return err } - extraSeed := func(n int, m int) error { + extraSeed := func(n, m int) error { pipe := client.Pipeline() for i := 1; i <= m; i++ { pipe.Set(ctx, fmt.Sprintf("A%02d", i), "x", 0).Err() diff --git a/json.go b/json.go index b3cadf4b7..bd9e4687b 100644 --- a/json.go +++ b/json.go @@ -26,7 +26,7 @@ type JSONCmdable interface { JSONForget(ctx context.Context, key, path string) *IntCmd JSONGet(ctx context.Context, key string, paths ...string) *JSONCmd JSONGetWithArgs(ctx context.Context, key string, options *JSONGetArgs, paths ...string) *JSONCmd - JSONMerge(ctx context.Context, key, path string, value string) *StatusCmd + JSONMerge(ctx context.Context, key, path, value string) *StatusCmd JSONMSetArgs(ctx context.Context, docs []JSONSetArgs) *StatusCmd JSONMSet(ctx context.Context, params ...interface{}) *StatusCmd JSONMGet(ctx context.Context, path string, keys ...string) *JSONSliceCmd @@ -450,7 +450,7 @@ func (c cmdable) JSONGetWithArgs(ctx context.Context, key string, options *JSONG // JSONMerge merges a given JSON value into matching paths. // For more information, see https://redis.io/commands/json.merge -func (c cmdable) JSONMerge(ctx context.Context, key, path string, value string) *StatusCmd { +func (c cmdable) JSONMerge(ctx context.Context, key, path, value string) *StatusCmd { args := []interface{}{"JSON.MERGE", key, path, value} cmd := NewStatusCmd(ctx, args...) _ = c(ctx, cmd) diff --git a/json_test.go b/json_test.go index 9139be3ac..48b115eda 100644 --- a/json_test.go +++ b/json_test.go @@ -678,7 +678,7 @@ var _ = Describe("JSON Commands", Label("json"), func() { var _ = Describe("Go-Redis Advanced JSON and RediSearch Tests", func() { var client *redis.Client - var ctx = context.Background() + ctx := context.Background() setupRedisClient := func(protocolVersion int) *redis.Client { return redis.NewClient(&redis.Options{ diff --git a/list_commands.go b/list_commands.go index 24a0de081..a915e627c 100644 --- a/list_commands.go +++ b/list_commands.go @@ -19,8 +19,8 @@ type ListCmdable interface { LMPop(ctx context.Context, direction string, count int64, keys ...string) *KeyValuesCmd LPop(ctx context.Context, key string) *StringCmd LPopCount(ctx context.Context, key string, count int) *StringSliceCmd - LPos(ctx context.Context, key string, value string, args LPosArgs) *IntCmd - LPosCount(ctx context.Context, key string, value string, count int64, args LPosArgs) *IntSliceCmd + LPos(ctx context.Context, key, value string, args LPosArgs) *IntCmd + LPosCount(ctx context.Context, key, value string, count int64, args LPosArgs) *IntSliceCmd LPush(ctx context.Context, key string, values ...interface{}) *IntCmd LPushX(ctx context.Context, key string, values ...interface{}) *IntCmd LRange(ctx context.Context, key string, start, stop int64) *StringSliceCmd @@ -152,7 +152,7 @@ type LPosArgs struct { Rank, MaxLen int64 } -func (c cmdable) LPos(ctx context.Context, key string, value string, a LPosArgs) *IntCmd { +func (c cmdable) LPos(ctx context.Context, key, value string, a LPosArgs) *IntCmd { args := []interface{}{"lpos", key, value} if a.Rank != 0 { args = append(args, "rank", a.Rank) @@ -166,7 +166,7 @@ func (c cmdable) LPos(ctx context.Context, key string, value string, a LPosArgs) return cmd } -func (c cmdable) LPosCount(ctx context.Context, key string, value string, count int64, a LPosArgs) *IntSliceCmd { +func (c cmdable) LPosCount(ctx context.Context, key, value string, count int64, a LPosArgs) *IntSliceCmd { args := []interface{}{"lpos", key, value, "count", count} if a.Rank != 0 { args = append(args, "rank", a.Rank) diff --git a/main_test.go b/main_test.go index 556e633e5..e3f40a8f4 100644 --- a/main_test.go +++ b/main_test.go @@ -12,6 +12,7 @@ import ( . "github.com/bsm/ginkgo/v2" . "github.com/bsm/gomega" + "github.com/redis/go-redis/v9" ) diff --git a/monitor_test.go b/monitor_test.go index ebb784853..bcbe51b3b 100644 --- a/monitor_test.go +++ b/monitor_test.go @@ -24,7 +24,6 @@ var _ = Describe("Monitor command", Label("monitor"), func() { } client = redis.NewClient(&redis.Options{Addr: redisPort}) Expect(client.FlushDB(ctx).Err()).NotTo(HaveOccurred()) - }) AfterEach(func() { diff --git a/options.go b/options.go index 0ebeec342..09a5826bd 100644 --- a/options.go +++ b/options.go @@ -59,13 +59,13 @@ type Options struct { Password string // CredentialsProvider allows the username and password to be updated // before reconnecting. It should return the current username and password. - CredentialsProvider func() (username string, password string) + CredentialsProvider func() (username, password string) // CredentialsProviderContext is an enhanced parameter of CredentialsProvider, // done to maintain API compatibility. In the future, // there might be a merge between CredentialsProviderContext and CredentialsProvider. // There will be a conflict between them; if CredentialsProviderContext exists, we will ignore CredentialsProvider. - CredentialsProviderContext func(ctx context.Context) (username string, password string, err error) + CredentialsProviderContext func(ctx context.Context) (username, password string, err error) // Database to be selected after connecting to the server. DB int diff --git a/osscluster.go b/osscluster.go index 20180464e..aa7bb2d2a 100644 --- a/osscluster.go +++ b/osscluster.go @@ -69,8 +69,8 @@ type ClusterOptions struct { Protocol int Username string Password string - CredentialsProvider func() (username string, password string) - CredentialsProviderContext func(ctx context.Context) (username string, password string, err error) + CredentialsProvider func() (username, password string) + CredentialsProviderContext func(ctx context.Context) (username, password string, err error) MaxRetries int MinRetryBackoff time.Duration @@ -778,7 +778,7 @@ func (c *clusterState) slotClosestNode(slot int) (*clusterNode, error) { return c.nodes.Random() } - var allNodesFailing = true + allNodesFailing := true var ( closestNonFailingNode *clusterNode closestNode *clusterNode diff --git a/probabilistic.go b/probabilistic.go index 02ca263cb..e2be22e98 100644 --- a/probabilistic.go +++ b/probabilistic.go @@ -39,9 +39,9 @@ type ProbabilisticCmdable interface { CFMExists(ctx context.Context, key string, elements ...interface{}) *BoolSliceCmd CFReserve(ctx context.Context, key string, capacity int64) *StatusCmd CFReserveWithArgs(ctx context.Context, key string, options *CFReserveOptions) *StatusCmd - CFReserveExpansion(ctx context.Context, key string, capacity int64, expansion int64) *StatusCmd - CFReserveBucketSize(ctx context.Context, key string, capacity int64, bucketsize int64) *StatusCmd - CFReserveMaxIterations(ctx context.Context, key string, capacity int64, maxiterations int64) *StatusCmd + CFReserveExpansion(ctx context.Context, key string, capacity, expansion int64) *StatusCmd + CFReserveBucketSize(ctx context.Context, key string, capacity, bucketsize int64) *StatusCmd + CFReserveMaxIterations(ctx context.Context, key string, capacity, maxiterations int64) *StatusCmd CFScanDump(ctx context.Context, key string, iterator int64) *ScanDumpCmd CFLoadChunk(ctx context.Context, key string, iterator int64, data interface{}) *StatusCmd @@ -61,7 +61,7 @@ type ProbabilisticCmdable interface { TopKListWithCount(ctx context.Context, key string) *MapStringIntCmd TopKQuery(ctx context.Context, key string, elements ...interface{}) *BoolSliceCmd TopKReserve(ctx context.Context, key string, k int64) *StatusCmd - TopKReserveWithOptions(ctx context.Context, key string, k int64, width, depth int64, decay float64) *StatusCmd + TopKReserveWithOptions(ctx context.Context, key string, k, width, depth int64, decay float64) *StatusCmd TDigestAdd(ctx context.Context, key string, elements ...float64) *StatusCmd TDigestByRank(ctx context.Context, key string, rank ...uint64) *FloatSliceCmd @@ -496,7 +496,7 @@ func (c cmdable) CFReserve(ctx context.Context, key string, capacity int64) *Sta // CFReserveExpansion creates an empty Cuckoo filter with the specified capacity and expansion rate. // For more information - https://redis.io/commands/cf.reserve/ -func (c cmdable) CFReserveExpansion(ctx context.Context, key string, capacity int64, expansion int64) *StatusCmd { +func (c cmdable) CFReserveExpansion(ctx context.Context, key string, capacity, expansion int64) *StatusCmd { args := []interface{}{"CF.RESERVE", key, capacity, "EXPANSION", expansion} cmd := NewStatusCmd(ctx, args...) _ = c(ctx, cmd) @@ -505,7 +505,7 @@ func (c cmdable) CFReserveExpansion(ctx context.Context, key string, capacity in // CFReserveBucketSize creates an empty Cuckoo filter with the specified capacity and bucket size. // For more information - https://redis.io/commands/cf.reserve/ -func (c cmdable) CFReserveBucketSize(ctx context.Context, key string, capacity int64, bucketsize int64) *StatusCmd { +func (c cmdable) CFReserveBucketSize(ctx context.Context, key string, capacity, bucketsize int64) *StatusCmd { args := []interface{}{"CF.RESERVE", key, capacity, "BUCKETSIZE", bucketsize} cmd := NewStatusCmd(ctx, args...) _ = c(ctx, cmd) @@ -514,7 +514,7 @@ func (c cmdable) CFReserveBucketSize(ctx context.Context, key string, capacity i // CFReserveMaxIterations creates an empty Cuckoo filter with the specified capacity and maximum number of iterations. // For more information - https://redis.io/commands/cf.reserve/ -func (c cmdable) CFReserveMaxIterations(ctx context.Context, key string, capacity int64, maxiterations int64) *StatusCmd { +func (c cmdable) CFReserveMaxIterations(ctx context.Context, key string, capacity, maxiterations int64) *StatusCmd { args := []interface{}{"CF.RESERVE", key, capacity, "MAXITERATIONS", maxiterations} cmd := NewStatusCmd(ctx, args...) _ = c(ctx, cmd) @@ -956,7 +956,7 @@ func (c cmdable) TopKReserve(ctx context.Context, key string, k int64) *StatusCm // TopKReserveWithOptions creates an empty Top-K filter with the specified number of top items to keep and additional options. // This function allows for specifying additional options such as width, depth and decay. // For more information - https://redis.io/commands/topk.reserve/ -func (c cmdable) TopKReserveWithOptions(ctx context.Context, key string, k int64, width, depth int64, decay float64) *StatusCmd { +func (c cmdable) TopKReserveWithOptions(ctx context.Context, key string, k, width, depth int64, decay float64) *StatusCmd { args := []interface{}{"TOPK.RESERVE", key, k, width, depth, decay} cmd := NewStatusCmd(ctx, args...) diff --git a/scripting_commands.go b/scripting_commands.go index af9c3397b..87329967e 100644 --- a/scripting_commands.go +++ b/scripting_commands.go @@ -201,7 +201,7 @@ func (c cmdable) FCallRO(ctx context.Context, function string, keys []string, ar return cmd } -func fcallArgs(command string, function string, keys []string, args ...interface{}) []interface{} { +func fcallArgs(command, function string, keys []string, args ...interface{}) []interface{} { cmdArgs := make([]interface{}, 3+len(keys), 3+len(keys)+len(args)) cmdArgs[0] = command cmdArgs[1] = function diff --git a/search_commands.go b/search_commands.go index b31baaa76..063cbce0a 100644 --- a/search_commands.go +++ b/search_commands.go @@ -1074,7 +1074,6 @@ func (c cmdable) FTCreate(ctx context.Context, index string, options *FTCreateOp } if schema.IndexMissing { args = append(args, "INDEXMISSING") - } } cmd := NewStatusCmd(ctx, args...) @@ -1411,6 +1410,7 @@ func (cmd *FTInfoCmd) RawVal() interface{} { func (cmd *FTInfoCmd) RawResult() (interface{}, error) { return cmd.rawVal, cmd.err } + func (cmd *FTInfoCmd) readReply(rd *proto.Reader) (err error) { n, err := rd.ReadMapLen() if err != nil { diff --git a/search_test.go b/search_test.go index 6bc8b1112..818a181fa 100644 --- a/search_test.go +++ b/search_test.go @@ -9,6 +9,7 @@ import ( . "github.com/bsm/ginkgo/v2" . "github.com/bsm/gomega" + "github.com/redis/go-redis/v9" ) @@ -100,7 +101,6 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() { docs := []interface{}{res4.Docs[0].ID, res4.Docs[1].ID} Expect(docs).To(ContainElement("doc1")) Expect(docs).To(ContainElement("doc2")) - }) It("should FTCreate and FTSearch sortby", Label("search", "ftcreate", "ftsearch"), func() { @@ -146,7 +146,6 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() { res1, err := client.FTSearchWithArgs(ctx, "txt", "search engine", &redis.FTSearchOptions{NoContent: true, Verbatim: true, LimitOffset: 0, Limit: 5}).Result() Expect(err).NotTo(HaveOccurred()) Expect(res1.Total).To(BeEquivalentTo(int64(1))) - }) It("should FTCreate NoIndex", Label("search", "ftcreate", "ftsearch"), func() { @@ -184,7 +183,6 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() { res7, err := client.FTSearchWithArgs(ctx, "idx", "*", &redis.FTSearchOptions{SortBy: []redis.FTSearchSortBy{{FieldName: "tag", Asc: true}}}).Result() Expect(err).NotTo(HaveOccurred()) Expect(res7.Docs[0].ID).To(BeEquivalentTo("doc1")) - }) It("should FTExplain", Label("search", "ftexplain"), func() { @@ -198,7 +196,6 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() { res1, err := client.FTExplain(ctx, "txt", "@f3:f3_val @f2:f2_val @f1:f1_val").Result() Expect(err).NotTo(HaveOccurred()) Expect(res1).ToNot(BeEmpty()) - }) It("should FTAlias", Label("search", "ftexplain"), func() { @@ -239,7 +236,6 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() { aliasDelRes, err := client.FTAliasDel(ctx, "mj23").Result() Expect(err).NotTo(HaveOccurred()) Expect(aliasDelRes).To(BeEquivalentTo("OK")) - }) It("should FTCreate and FTSearch textfield, sortable and nostem ", Label("search", "ftcreate", "ftsearch"), func() { @@ -252,7 +248,6 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() { Expect(err).NotTo(HaveOccurred()) Expect(resInfo.Attributes[0].Sortable).To(BeTrue()) Expect(resInfo.Attributes[0].NoStem).To(BeTrue()) - }) It("should FTAlter", Label("search", "ftcreate", "ftsearch", "ftalter"), func() { @@ -476,7 +471,6 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() { res, err = client.FTConfigGet(ctx, "MINPREFIX").Result() Expect(err).NotTo(HaveOccurred()) Expect(res).To(BeEquivalentTo(map[string]interface{}{"MINPREFIX": "1"})) - }) It("should FTAggregate GroupBy ", Label("search", "ftaggregate"), func() { @@ -582,7 +576,6 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() { ContainElement("RedisAI"), ContainElement("RedisJson"), )) - }) It("should FTAggregate sort and limit", Label("search", "ftaggregate"), func() { @@ -777,7 +770,6 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() { Expect(err).NotTo(HaveOccurred()) Expect(res.Rows[0].Fields["CreatedDateTimeUTC"]).To(Or(BeEquivalentTo("6373878785249699840"), BeEquivalentTo("6373878758592700416"))) Expect(res.Rows[1].Fields["CreatedDateTimeUTC"]).To(Or(BeEquivalentTo("6373878785249699840"), BeEquivalentTo("6373878758592700416"))) - }) It("should FTAggregate filter", Label("search", "ftaggregate"), func() { @@ -889,7 +881,6 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() { }) It("should FTCreate json", Label("search", "ftcreate"), func() { - text1 := &redis.FieldSchema{FieldName: "$.name", FieldType: redis.SearchFieldTypeText} val, err := client.FTCreate(ctx, "idx1", &redis.FTCreateOptions{OnJSON: true, Prefix: []interface{}{"king:"}}, text1).Result() Expect(err).NotTo(HaveOccurred()) @@ -907,7 +898,6 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() { }) It("should FTCreate json fields as names", Label("search", "ftcreate"), func() { - text1 := &redis.FieldSchema{FieldName: "$.name", FieldType: redis.SearchFieldTypeText, As: "name"} num1 := &redis.FieldSchema{FieldName: "$.age", FieldType: redis.SearchFieldTypeNumeric, As: "just_a_number"} val, err := client.FTCreate(ctx, "idx1", &redis.FTCreateOptions{OnJSON: true}, text1, num1).Result() @@ -926,7 +916,6 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() { }) It("should FTCreate CaseSensitive", Label("search", "ftcreate"), func() { - tag1 := &redis.FieldSchema{FieldName: "t", FieldType: redis.SearchFieldTypeTag, CaseSensitive: false} val, err := client.FTCreate(ctx, "idx1", &redis.FTCreateOptions{}, tag1).Result() Expect(err).NotTo(HaveOccurred()) @@ -956,7 +945,6 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() { Expect(err).NotTo(HaveOccurred()) Expect(res.Total).To(BeEquivalentTo(1)) Expect(res.Docs[0].ID).To(BeEquivalentTo("1")) - }) It("should FTSearch ReturnFields", Label("search", "ftsearch"), func() { @@ -985,7 +973,6 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() { }) It("should FTSynUpdate", Label("search", "ftsynupdate"), func() { - text1 := &redis.FieldSchema{FieldName: "title", FieldType: redis.SearchFieldTypeText} text2 := &redis.FieldSchema{FieldName: "body", FieldType: redis.SearchFieldTypeText} val, err := client.FTCreate(ctx, "idx1", &redis.FTCreateOptions{OnHash: true}, text1, text2).Result() @@ -1011,7 +998,6 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() { }) It("should FTSynDump", Label("search", "ftsyndump"), func() { - text1 := &redis.FieldSchema{FieldName: "title", FieldType: redis.SearchFieldTypeText} text2 := &redis.FieldSchema{FieldName: "body", FieldType: redis.SearchFieldTypeText} val, err := client.FTCreate(ctx, "idx1", &redis.FTCreateOptions{OnHash: true}, text1, text2).Result() @@ -1045,11 +1031,9 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() { Expect(resSynDump[4].Synonyms).To(Or(BeEquivalentTo([]string{"id1"}), BeEquivalentTo([]string{"id1", "id1"}))) Expect(resSynDump[5].Term).To(BeEquivalentTo("offspring")) Expect(resSynDump[5].Synonyms).To(BeEquivalentTo([]string{"id1"})) - }) It("should FTCreate json with alias", Label("search", "ftcreate"), func() { - text1 := &redis.FieldSchema{FieldName: "$.name", FieldType: redis.SearchFieldTypeText, As: "name"} num1 := &redis.FieldSchema{FieldName: "$.num", FieldType: redis.SearchFieldTypeNumeric, As: "num"} val, err := client.FTCreate(ctx, "idx1", &redis.FTCreateOptions{OnJSON: true, Prefix: []interface{}{"king:"}}, text1, num1).Result() @@ -1074,7 +1058,6 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() { }) It("should FTCreate json with multipath", Label("search", "ftcreate"), func() { - tag1 := &redis.FieldSchema{FieldName: "$..name", FieldType: redis.SearchFieldTypeTag, As: "name"} val, err := client.FTCreate(ctx, "idx1", &redis.FTCreateOptions{OnJSON: true, Prefix: []interface{}{"king:"}}, tag1).Result() Expect(err).NotTo(HaveOccurred()) @@ -1091,7 +1074,6 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() { }) It("should FTCreate json with jsonpath", Label("search", "ftcreate"), func() { - text1 := &redis.FieldSchema{FieldName: `$["prod:name"]`, FieldType: redis.SearchFieldTypeText, As: "name"} text2 := &redis.FieldSchema{FieldName: `$.prod:name`, FieldType: redis.SearchFieldTypeText, As: "name_unsupported"} val, err := client.FTCreate(ctx, "idx1", &redis.FTCreateOptions{OnJSON: true}, text1, text2).Result() @@ -1116,7 +1098,6 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() { Expect(res.Total).To(BeEquivalentTo(1)) Expect(res.Docs[0].ID).To(BeEquivalentTo("doc:1")) Expect(res.Docs[0].Fields["name"]).To(BeEquivalentTo("RediSearch")) - }) It("should FTCreate VECTOR", Label("search", "ftcreate"), func() { @@ -1208,7 +1189,6 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() { Expect(res1.Total).To(BeEquivalentTo(int64(2))) Expect(res1.Docs[0].ID).To(BeEquivalentTo("doc1")) Expect(res1.Docs[1].ID).To(BeEquivalentTo("doc2")) - }) It("should FTCreate and FTSearch numeric params", Label("search", "ftcreate", "ftsearch"), func() { @@ -1226,7 +1206,6 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() { Expect(res1.Total).To(BeEquivalentTo(int64(2))) Expect(res1.Docs[0].ID).To(BeEquivalentTo("doc1")) Expect(res1.Docs[1].ID).To(BeEquivalentTo("doc2")) - }) It("should FTCreate and FTSearch geo params", Label("search", "ftcreate", "ftsearch"), func() { @@ -1245,7 +1224,6 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() { Expect(res1.Docs[0].ID).To(BeEquivalentTo("doc1")) Expect(res1.Docs[1].ID).To(BeEquivalentTo("doc2")) Expect(res1.Docs[2].ID).To(BeEquivalentTo("doc3")) - }) It("should FTConfigGet return multiple fields", Label("search", "NonRedisEnterprise"), func() { @@ -2197,7 +2175,6 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() { Expect(res.Rows[0].Fields["minValue"]).To(BeEquivalentTo("inf")) Expect(res.Rows[0].Fields["maxValue"]).To(BeEquivalentTo("-inf")) }) - }) func _assert_geosearch_result(result *redis.FTSearchResult, expectedDocIDs []string) { @@ -2210,7 +2187,6 @@ func _assert_geosearch_result(result *redis.FTSearchResult, expectedDocIDs []str } var _ = Describe("RediSearch FT.Config with Resp2 and Resp3", Label("search", "NonRedisEnterprise"), func() { - var clientResp2 *redis.Client var clientResp3 *redis.Client BeforeEach(func() { @@ -2297,7 +2273,6 @@ var _ = Describe("RediSearch commands Resp 3", Label("search"), func() { Expect(rawRes).To(BeNil()) Expect(rawVal).To(BeNil()) }).Should(Panic()) - }) It("should handle FTInfo with Unstable RESP3 Search Module and without stability", Label("search", "ftcreate", "ftinfo"), func() { diff --git a/sentinel_test.go b/sentinel_test.go index cde7f956d..511400dd2 100644 --- a/sentinel_test.go +++ b/sentinel_test.go @@ -7,6 +7,7 @@ import ( . "github.com/bsm/ginkgo/v2" . "github.com/bsm/gomega" + "github.com/redis/go-redis/v9" ) @@ -41,7 +42,7 @@ var _ = Describe("Sentinel resolution", func() { client := redis.NewFailoverClient(&redis.FailoverOptions{ MasterName: sentinelName, SentinelAddrs: sentinelAddrs, - MaxRetries: -1, + MaxRetries: -1, }) err := client.Ping(shortCtx).Err() @@ -292,7 +293,6 @@ var _ = Describe("NewFailoverClusterClient", func() { Expect(msg.Channel).To(Equal("foo")) Expect(msg.Payload).To(Equal("hello")) Expect(sub.Close()).NotTo(HaveOccurred()) - }) It("should sentinel cluster client setname", func() { diff --git a/stream_commands.go b/stream_commands.go index 6d7b22922..65e8745a3 100644 --- a/stream_commands.go +++ b/stream_commands.go @@ -11,8 +11,8 @@ type StreamCmdable interface { XLen(ctx context.Context, stream string) *IntCmd XRange(ctx context.Context, stream, start, stop string) *XMessageSliceCmd XRangeN(ctx context.Context, stream, start, stop string, count int64) *XMessageSliceCmd - XRevRange(ctx context.Context, stream string, start, stop string) *XMessageSliceCmd - XRevRangeN(ctx context.Context, stream string, start, stop string, count int64) *XMessageSliceCmd + XRevRange(ctx context.Context, stream, start, stop string) *XMessageSliceCmd + XRevRangeN(ctx context.Context, stream, start, stop string, count int64) *XMessageSliceCmd XRead(ctx context.Context, a *XReadArgs) *XStreamSliceCmd XReadStreams(ctx context.Context, streams ...string) *XStreamSliceCmd XGroupCreate(ctx context.Context, stream, group, start string) *StatusCmd @@ -31,12 +31,12 @@ type StreamCmdable interface { XAutoClaimJustID(ctx context.Context, a *XAutoClaimArgs) *XAutoClaimJustIDCmd XTrimMaxLen(ctx context.Context, key string, maxLen int64) *IntCmd XTrimMaxLenApprox(ctx context.Context, key string, maxLen, limit int64) *IntCmd - XTrimMinID(ctx context.Context, key string, minID string) *IntCmd - XTrimMinIDApprox(ctx context.Context, key string, minID string, limit int64) *IntCmd + XTrimMinID(ctx context.Context, key, minID string) *IntCmd + XTrimMinIDApprox(ctx context.Context, key, minID string, limit int64) *IntCmd XInfoGroups(ctx context.Context, key string) *XInfoGroupsCmd XInfoStream(ctx context.Context, key string) *XInfoStreamCmd XInfoStreamFull(ctx context.Context, key string, count int) *XInfoStreamFullCmd - XInfoConsumers(ctx context.Context, key string, group string) *XInfoConsumersCmd + XInfoConsumers(ctx context.Context, key, group string) *XInfoConsumersCmd } // XAddArgs accepts values in the following formats: @@ -410,15 +410,15 @@ func (c cmdable) XTrimMaxLenApprox(ctx context.Context, key string, maxLen, limi return c.xTrim(ctx, key, "maxlen", true, maxLen, limit) } -func (c cmdable) XTrimMinID(ctx context.Context, key string, minID string) *IntCmd { +func (c cmdable) XTrimMinID(ctx context.Context, key, minID string) *IntCmd { return c.xTrim(ctx, key, "minid", false, minID, 0) } -func (c cmdable) XTrimMinIDApprox(ctx context.Context, key string, minID string, limit int64) *IntCmd { +func (c cmdable) XTrimMinIDApprox(ctx context.Context, key, minID string, limit int64) *IntCmd { return c.xTrim(ctx, key, "minid", true, minID, limit) } -func (c cmdable) XInfoConsumers(ctx context.Context, key string, group string) *XInfoConsumersCmd { +func (c cmdable) XInfoConsumers(ctx context.Context, key, group string) *XInfoConsumersCmd { cmd := NewXInfoConsumersCmd(ctx, key, group) _ = c(ctx, cmd) return cmd diff --git a/timeseries_commands.go b/timeseries_commands.go index 82d8cdfcf..b7cf6360e 100644 --- a/timeseries_commands.go +++ b/timeseries_commands.go @@ -13,28 +13,28 @@ type TimeseriesCmdable interface { TSCreate(ctx context.Context, key string) *StatusCmd TSCreateWithArgs(ctx context.Context, key string, options *TSOptions) *StatusCmd TSAlter(ctx context.Context, key string, options *TSAlterOptions) *StatusCmd - TSCreateRule(ctx context.Context, sourceKey string, destKey string, aggregator Aggregator, bucketDuration int) *StatusCmd - TSCreateRuleWithArgs(ctx context.Context, sourceKey string, destKey string, aggregator Aggregator, bucketDuration int, options *TSCreateRuleOptions) *StatusCmd + TSCreateRule(ctx context.Context, sourceKey, destKey string, aggregator Aggregator, bucketDuration int) *StatusCmd + TSCreateRuleWithArgs(ctx context.Context, sourceKey, destKey string, aggregator Aggregator, bucketDuration int, options *TSCreateRuleOptions) *StatusCmd TSIncrBy(ctx context.Context, Key string, timestamp float64) *IntCmd TSIncrByWithArgs(ctx context.Context, key string, timestamp float64, options *TSIncrDecrOptions) *IntCmd TSDecrBy(ctx context.Context, Key string, timestamp float64) *IntCmd TSDecrByWithArgs(ctx context.Context, key string, timestamp float64, options *TSIncrDecrOptions) *IntCmd - TSDel(ctx context.Context, Key string, fromTimestamp int, toTimestamp int) *IntCmd - TSDeleteRule(ctx context.Context, sourceKey string, destKey string) *StatusCmd + TSDel(ctx context.Context, Key string, fromTimestamp, toTimestamp int) *IntCmd + TSDeleteRule(ctx context.Context, sourceKey, destKey string) *StatusCmd TSGet(ctx context.Context, key string) *TSTimestampValueCmd TSGetWithArgs(ctx context.Context, key string, options *TSGetOptions) *TSTimestampValueCmd TSInfo(ctx context.Context, key string) *MapStringInterfaceCmd TSInfoWithArgs(ctx context.Context, key string, options *TSInfoOptions) *MapStringInterfaceCmd TSMAdd(ctx context.Context, ktvSlices [][]interface{}) *IntSliceCmd TSQueryIndex(ctx context.Context, filterExpr []string) *StringSliceCmd - TSRevRange(ctx context.Context, key string, fromTimestamp int, toTimestamp int) *TSTimestampValueSliceCmd - TSRevRangeWithArgs(ctx context.Context, key string, fromTimestamp int, toTimestamp int, options *TSRevRangeOptions) *TSTimestampValueSliceCmd - TSRange(ctx context.Context, key string, fromTimestamp int, toTimestamp int) *TSTimestampValueSliceCmd - TSRangeWithArgs(ctx context.Context, key string, fromTimestamp int, toTimestamp int, options *TSRangeOptions) *TSTimestampValueSliceCmd - TSMRange(ctx context.Context, fromTimestamp int, toTimestamp int, filterExpr []string) *MapStringSliceInterfaceCmd - TSMRangeWithArgs(ctx context.Context, fromTimestamp int, toTimestamp int, filterExpr []string, options *TSMRangeOptions) *MapStringSliceInterfaceCmd - TSMRevRange(ctx context.Context, fromTimestamp int, toTimestamp int, filterExpr []string) *MapStringSliceInterfaceCmd - TSMRevRangeWithArgs(ctx context.Context, fromTimestamp int, toTimestamp int, filterExpr []string, options *TSMRevRangeOptions) *MapStringSliceInterfaceCmd + TSRevRange(ctx context.Context, key string, fromTimestamp, toTimestamp int) *TSTimestampValueSliceCmd + TSRevRangeWithArgs(ctx context.Context, key string, fromTimestamp, toTimestamp int, options *TSRevRangeOptions) *TSTimestampValueSliceCmd + TSRange(ctx context.Context, key string, fromTimestamp, toTimestamp int) *TSTimestampValueSliceCmd + TSRangeWithArgs(ctx context.Context, key string, fromTimestamp, toTimestamp int, options *TSRangeOptions) *TSTimestampValueSliceCmd + TSMRange(ctx context.Context, fromTimestamp, toTimestamp int, filterExpr []string) *MapStringSliceInterfaceCmd + TSMRangeWithArgs(ctx context.Context, fromTimestamp, toTimestamp int, filterExpr []string, options *TSMRangeOptions) *MapStringSliceInterfaceCmd + TSMRevRange(ctx context.Context, fromTimestamp, toTimestamp int, filterExpr []string) *MapStringSliceInterfaceCmd + TSMRevRangeWithArgs(ctx context.Context, fromTimestamp, toTimestamp int, filterExpr []string, options *TSMRevRangeOptions) *MapStringSliceInterfaceCmd TSMGet(ctx context.Context, filters []string) *MapStringSliceInterfaceCmd TSMGetWithArgs(ctx context.Context, filters []string, options *TSMGetOptions) *MapStringSliceInterfaceCmd } @@ -316,7 +316,7 @@ func (c cmdable) TSAlter(ctx context.Context, key string, options *TSAlterOption // TSCreateRule - Creates a compaction rule from sourceKey to destKey. // For more information - https://redis.io/commands/ts.createrule/ -func (c cmdable) TSCreateRule(ctx context.Context, sourceKey string, destKey string, aggregator Aggregator, bucketDuration int) *StatusCmd { +func (c cmdable) TSCreateRule(ctx context.Context, sourceKey, destKey string, aggregator Aggregator, bucketDuration int) *StatusCmd { args := []interface{}{"TS.CREATERULE", sourceKey, destKey, "AGGREGATION", aggregator.String(), bucketDuration} cmd := NewStatusCmd(ctx, args...) _ = c(ctx, cmd) @@ -327,7 +327,7 @@ func (c cmdable) TSCreateRule(ctx context.Context, sourceKey string, destKey str // This function allows for specifying additional option such as: // alignTimestamp. // For more information - https://redis.io/commands/ts.createrule/ -func (c cmdable) TSCreateRuleWithArgs(ctx context.Context, sourceKey string, destKey string, aggregator Aggregator, bucketDuration int, options *TSCreateRuleOptions) *StatusCmd { +func (c cmdable) TSCreateRuleWithArgs(ctx context.Context, sourceKey, destKey string, aggregator Aggregator, bucketDuration int, options *TSCreateRuleOptions) *StatusCmd { args := []interface{}{"TS.CREATERULE", sourceKey, destKey, "AGGREGATION", aggregator.String(), bucketDuration} if options != nil { if options.alignTimestamp != 0 { @@ -433,7 +433,7 @@ func (c cmdable) TSDecrByWithArgs(ctx context.Context, key string, timestamp flo // TSDel - Deletes a range of samples from a time-series key. // For more information - https://redis.io/commands/ts.del/ -func (c cmdable) TSDel(ctx context.Context, Key string, fromTimestamp int, toTimestamp int) *IntCmd { +func (c cmdable) TSDel(ctx context.Context, Key string, fromTimestamp, toTimestamp int) *IntCmd { args := []interface{}{"TS.DEL", Key, fromTimestamp, toTimestamp} cmd := NewIntCmd(ctx, args...) _ = c(ctx, cmd) @@ -442,7 +442,7 @@ func (c cmdable) TSDel(ctx context.Context, Key string, fromTimestamp int, toTim // TSDeleteRule - Deletes a compaction rule from sourceKey to destKey. // For more information - https://redis.io/commands/ts.deleterule/ -func (c cmdable) TSDeleteRule(ctx context.Context, sourceKey string, destKey string) *StatusCmd { +func (c cmdable) TSDeleteRule(ctx context.Context, sourceKey, destKey string) *StatusCmd { args := []interface{}{"TS.DELETERULE", sourceKey, destKey} cmd := NewStatusCmd(ctx, args...) _ = c(ctx, cmd) @@ -586,7 +586,7 @@ func (c cmdable) TSQueryIndex(ctx context.Context, filterExpr []string) *StringS // TSRevRange - Returns a range of samples from a time-series key in reverse order. // For more information - https://redis.io/commands/ts.revrange/ -func (c cmdable) TSRevRange(ctx context.Context, key string, fromTimestamp int, toTimestamp int) *TSTimestampValueSliceCmd { +func (c cmdable) TSRevRange(ctx context.Context, key string, fromTimestamp, toTimestamp int) *TSTimestampValueSliceCmd { args := []interface{}{"TS.REVRANGE", key, fromTimestamp, toTimestamp} cmd := newTSTimestampValueSliceCmd(ctx, args...) _ = c(ctx, cmd) @@ -598,7 +598,7 @@ func (c cmdable) TSRevRange(ctx context.Context, key string, fromTimestamp int, // Latest, FilterByTS, FilterByValue, Count, Align, Aggregator, // BucketDuration, BucketTimestamp and Empty. // For more information - https://redis.io/commands/ts.revrange/ -func (c cmdable) TSRevRangeWithArgs(ctx context.Context, key string, fromTimestamp int, toTimestamp int, options *TSRevRangeOptions) *TSTimestampValueSliceCmd { +func (c cmdable) TSRevRangeWithArgs(ctx context.Context, key string, fromTimestamp, toTimestamp int, options *TSRevRangeOptions) *TSTimestampValueSliceCmd { args := []interface{}{"TS.REVRANGE", key, fromTimestamp, toTimestamp} if options != nil { if options.Latest { @@ -642,7 +642,7 @@ func (c cmdable) TSRevRangeWithArgs(ctx context.Context, key string, fromTimesta // TSRange - Returns a range of samples from a time-series key. // For more information - https://redis.io/commands/ts.range/ -func (c cmdable) TSRange(ctx context.Context, key string, fromTimestamp int, toTimestamp int) *TSTimestampValueSliceCmd { +func (c cmdable) TSRange(ctx context.Context, key string, fromTimestamp, toTimestamp int) *TSTimestampValueSliceCmd { args := []interface{}{"TS.RANGE", key, fromTimestamp, toTimestamp} cmd := newTSTimestampValueSliceCmd(ctx, args...) _ = c(ctx, cmd) @@ -654,7 +654,7 @@ func (c cmdable) TSRange(ctx context.Context, key string, fromTimestamp int, toT // Latest, FilterByTS, FilterByValue, Count, Align, Aggregator, // BucketDuration, BucketTimestamp and Empty. // For more information - https://redis.io/commands/ts.range/ -func (c cmdable) TSRangeWithArgs(ctx context.Context, key string, fromTimestamp int, toTimestamp int, options *TSRangeOptions) *TSTimestampValueSliceCmd { +func (c cmdable) TSRangeWithArgs(ctx context.Context, key string, fromTimestamp, toTimestamp int, options *TSRangeOptions) *TSTimestampValueSliceCmd { args := []interface{}{"TS.RANGE", key, fromTimestamp, toTimestamp} if options != nil { if options.Latest { @@ -754,7 +754,7 @@ func (cmd *TSTimestampValueSliceCmd) readReply(rd *proto.Reader) (err error) { // TSMRange - Returns a range of samples from multiple time-series keys. // For more information - https://redis.io/commands/ts.mrange/ -func (c cmdable) TSMRange(ctx context.Context, fromTimestamp int, toTimestamp int, filterExpr []string) *MapStringSliceInterfaceCmd { +func (c cmdable) TSMRange(ctx context.Context, fromTimestamp, toTimestamp int, filterExpr []string) *MapStringSliceInterfaceCmd { args := []interface{}{"TS.MRANGE", fromTimestamp, toTimestamp, "FILTER"} for _, f := range filterExpr { args = append(args, f) @@ -770,7 +770,7 @@ func (c cmdable) TSMRange(ctx context.Context, fromTimestamp int, toTimestamp in // Count, Align, Aggregator, BucketDuration, BucketTimestamp, // Empty, GroupByLabel and Reducer. // For more information - https://redis.io/commands/ts.mrange/ -func (c cmdable) TSMRangeWithArgs(ctx context.Context, fromTimestamp int, toTimestamp int, filterExpr []string, options *TSMRangeOptions) *MapStringSliceInterfaceCmd { +func (c cmdable) TSMRangeWithArgs(ctx context.Context, fromTimestamp, toTimestamp int, filterExpr []string, options *TSMRangeOptions) *MapStringSliceInterfaceCmd { args := []interface{}{"TS.MRANGE", fromTimestamp, toTimestamp} if options != nil { if options.Latest { @@ -833,7 +833,7 @@ func (c cmdable) TSMRangeWithArgs(ctx context.Context, fromTimestamp int, toTime // TSMRevRange - Returns a range of samples from multiple time-series keys in reverse order. // For more information - https://redis.io/commands/ts.mrevrange/ -func (c cmdable) TSMRevRange(ctx context.Context, fromTimestamp int, toTimestamp int, filterExpr []string) *MapStringSliceInterfaceCmd { +func (c cmdable) TSMRevRange(ctx context.Context, fromTimestamp, toTimestamp int, filterExpr []string) *MapStringSliceInterfaceCmd { args := []interface{}{"TS.MREVRANGE", fromTimestamp, toTimestamp, "FILTER"} for _, f := range filterExpr { args = append(args, f) @@ -849,7 +849,7 @@ func (c cmdable) TSMRevRange(ctx context.Context, fromTimestamp int, toTimestamp // Count, Align, Aggregator, BucketDuration, BucketTimestamp, // Empty, GroupByLabel and Reducer. // For more information - https://redis.io/commands/ts.mrevrange/ -func (c cmdable) TSMRevRangeWithArgs(ctx context.Context, fromTimestamp int, toTimestamp int, filterExpr []string, options *TSMRevRangeOptions) *MapStringSliceInterfaceCmd { +func (c cmdable) TSMRevRangeWithArgs(ctx context.Context, fromTimestamp, toTimestamp int, filterExpr []string, options *TSMRevRangeOptions) *MapStringSliceInterfaceCmd { args := []interface{}{"TS.MREVRANGE", fromTimestamp, toTimestamp} if options != nil { if options.Latest { diff --git a/timeseries_commands_test.go b/timeseries_commands_test.go index d0d865b48..f7cb9ae40 100644 --- a/timeseries_commands_test.go +++ b/timeseries_commands_test.go @@ -115,7 +115,8 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() { {Timestamp: 1000, Value: 1.0}, {Timestamp: 1010, Value: 11.0}, {Timestamp: 1020, Value: 11.5}, - {Timestamp: 1021, Value: 22.0}})) + {Timestamp: 1021, Value: 22.0}, + })) // Test insertion filters with other duplicate policy opt = &redis.TSOptions{IgnoreMaxTimeDiff: 5, IgnoreMaxValDiff: 10.0} result, err = client.TSCreateWithArgs(ctx, "ts-if-2", opt).Result() @@ -137,7 +138,8 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() { Expect(rangePoints).To(BeEquivalentTo([]redis.TSTimestampValue{ {Timestamp: 1000, Value: 1.0}, {Timestamp: 1010, Value: 11.0}, - {Timestamp: 1013, Value: 10.0}})) + {Timestamp: 1013, Value: 10.0}, + })) }) It("should TSAdd and TSAddWithArgs", Label("timeseries", "tsadd", "tsaddWithArgs", "NonRedisEnterprise"), func() { SkipBeforeRedisVersion(7.4, "older redis stack has different results for timeseries module") @@ -309,7 +311,8 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() { Expect(rangePoints).To(BeEquivalentTo([]redis.TSTimestampValue{ {Timestamp: 1000, Value: 1.0}, {Timestamp: 1010, Value: 11.0}, - {Timestamp: 1013, Value: 10.0}})) + {Timestamp: 1013, Value: 10.0}, + })) }) It("should TSCreateRule and TSDeleteRule", Label("timeseries", "tscreaterule", "tsdeleterule"), func() { diff --git a/universal.go b/universal.go index 3d91dd493..46d5640da 100644 --- a/universal.go +++ b/universal.go @@ -259,13 +259,13 @@ var ( // NewUniversalClient returns a new multi client. The type of the returned client depends // on the following conditions: // -// 1. If the MasterName option is specified with RouteByLatency, RouteRandomly or IsClusterMode, -// a FailoverClusterClient is returned. -// 2. If the MasterName option is specified without RouteByLatency, RouteRandomly or IsClusterMode, -// a sentinel-backed FailoverClient is returned. -// 3. If the number of Addrs is two or more, or IsClusterMode option is specified, -// a ClusterClient is returned. -// 4. Otherwise, a single-node Client is returned. +// 1. If the MasterName option is specified with RouteByLatency, RouteRandomly or IsClusterMode, +// a FailoverClusterClient is returned. +// 2. If the MasterName option is specified without RouteByLatency, RouteRandomly or IsClusterMode, +// a sentinel-backed FailoverClient is returned. +// 3. If the number of Addrs is two or more, or IsClusterMode option is specified, +// a ClusterClient is returned. +// 4. Otherwise, a single-node Client is returned. func NewUniversalClient(opts *UniversalOptions) UniversalClient { switch { case opts.MasterName != "" && (opts.RouteByLatency || opts.RouteRandomly || opts.IsClusterMode):