From e8ad794e965a1b4e2ba63fe9a6975a14ebf289b9 Mon Sep 17 00:00:00 2001 From: Tiago Peczenyj Date: Wed, 20 Sep 2023 13:03:44 +0200 Subject: [PATCH] Format code and fix go vet (#2696) * run go fix ./... Signed-off-by: Tiago Peczenyj * run make fmt Signed-off-by: Tiago Peczenyj * fix go vet ./... issues * Update README.md Reorder imports with the rules defined in the Makefile as if we run `make fmt` * run gofumpt -w . * update Makefile to use gofumpt instead gofmt * increment makefile * format test * format tests Signed-off-by: Tiago Peczenyj --------- Signed-off-by: Tiago Peczenyj Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com> --- Makefile | 4 ++-- README.md | 6 +++-- cluster_test.go | 3 ++- command.go | 2 +- commands.go | 3 ++- commands_test.go | 23 ++++--------------- doctests/lpush_lrange_test.go | 3 ++- doctests/set_get_test.go | 3 ++- example/del-keys-without-ttl/main.go | 3 ++- extra/redisotel/metrics.go | 3 ++- extra/redisprometheus/collector.go | 12 +++++----- internal/customvet/checks/setval/setval.go | 1 + .../customvet/checks/setval/setval_test.go | 3 ++- internal/customvet/main.go | 3 ++- internal/pool/conn_check.go | 1 - internal/pool/conn_check_dummy.go | 1 - internal/pool/conn_check_test.go | 1 - internal/util/safe.go | 1 - internal/util/unsafe.go | 1 - main_test.go | 6 +++-- options_test.go | 1 - probabilistic.go | 1 + probabilistic_test.go | 8 +------ redis_gears.go | 5 ---- redis_gears_test.go | 4 +--- redis_timeseries.go | 9 -------- redis_timeseries_test.go | 15 +----------- ring.go | 1 - 28 files changed, 42 insertions(+), 85 deletions(-) diff --git a/Makefile b/Makefile index cf1f6428d..6fe9c33ed 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ testdeps: testdata/redis/src/redis-server bench: testdeps go test ./... -test.run=NONE -test.bench=. -test.benchmem -.PHONY: all test testdeps bench +.PHONY: all test testdeps bench fmt testdata/redis: mkdir -p $@ @@ -29,7 +29,7 @@ testdata/redis/src/redis-server: testdata/redis cd $< && make all fmt: - gofmt -w -s ./ + gofumpt -w ./ goimports -w -local github.com/redis/go-redis ./ go_mod_tidy: diff --git a/README.md b/README.md index 1005868c0..18095eeba 100644 --- a/README.md +++ b/README.md @@ -69,8 +69,9 @@ go get github.com/redis/go-redis/v9 ```go import ( "context" - "github.com/redis/go-redis/v9" "fmt" + + "github.com/redis/go-redis/v9" ) var ctx = context.Background() @@ -125,8 +126,9 @@ go-redis also supports connecting via the [redis uri specification](https://gith ```go import ( "context" - "github.com/redis/go-redis/v9" "fmt" + + "github.com/redis/go-redis/v9" ) var ctx = context.Background() diff --git a/cluster_test.go b/cluster_test.go index d3b4474a2..3d2f80711 100644 --- a/cluster_test.go +++ b/cluster_test.go @@ -13,6 +13,7 @@ import ( . "github.com/bsm/ginkgo/v2" . "github.com/bsm/gomega" + "github.com/redis/go-redis/v9" "github.com/redis/go-redis/v9/internal/hashtag" ) @@ -1457,7 +1458,7 @@ var _ = Describe("ClusterClient timeout", func() { }) var _ = Describe("ClusterClient ParseURL", func() { - var cases = []struct { + cases := []struct { test string url string o *redis.ClusterOptions // expected value diff --git a/command.go b/command.go index 1700b328c..00e356bbd 100644 --- a/command.go +++ b/command.go @@ -4324,7 +4324,6 @@ func (cmd *FunctionStatsCmd) readDuration(rd *proto.Reader) (time.Duration, erro } func (cmd *FunctionStatsCmd) readCommand(rd *proto.Reader) ([]string, error) { - n, err := rd.ReadArrayLen() if err != nil { return nil, err @@ -4341,6 +4340,7 @@ func (cmd *FunctionStatsCmd) readCommand(rd *proto.Reader) ([]string, error) { return command, nil } + func (cmd *FunctionStatsCmd) readRunningScripts(rd *proto.Reader) ([]RunningScript, bool, error) { n, err := rd.ReadArrayLen() if err != nil { diff --git a/commands.go b/commands.go index 96d909911..dbbad083f 100644 --- a/commands.go +++ b/commands.go @@ -609,7 +609,8 @@ func (info LibraryInfo) Validate() error { // Hello Set the resp protocol used. func (c statefulCmdable) Hello(ctx context.Context, - ver int, username, password, clientName string) *MapStringInterfaceCmd { + ver int, username, password, clientName string, +) *MapStringInterfaceCmd { args := make([]interface{}, 0, 7) args = append(args, "hello", ver) if password != "" { diff --git a/commands_test.go b/commands_test.go index 9b1c63e81..812d682d6 100644 --- a/commands_test.go +++ b/commands_test.go @@ -232,7 +232,6 @@ var _ = Describe("Commands", func() { }) It("should ClientSetInfo", func() { - pipe := client.Pipeline() // Test setting the libName @@ -413,7 +412,6 @@ var _ = Describe("Commands", func() { }) It("should filter commands by ACL category", func() { - filter := &redis.FilterBy{ ACLCat: "admin", } @@ -580,7 +578,6 @@ var _ = Describe("Commands", func() { n, err = client.Exists(ctx, "key").Result() Expect(err).NotTo(HaveOccurred()) Expect(n).To(Equal(int64(0))) - }) It("should Keys", func() { @@ -727,7 +724,6 @@ var _ = Describe("Commands", func() { }) It("should PExpireTime", func() { - // The command returns -1 if the key exists but has no associated expiration time. // The command returns -2 if the key does not exist. pExpireTime := client.PExpireTime(ctx, "key") @@ -966,7 +962,6 @@ var _ = Describe("Commands", func() { }) It("should ExpireTime", func() { - // The command returns -1 if the key exists but has no associated expiration time. // The command returns -2 if the key does not exist. expireTimeCmd := client.ExpireTime(ctx, "key") @@ -988,7 +983,6 @@ var _ = Describe("Commands", func() { }) It("should TTL", func() { - // The command returns -1 if the key exists but has no associated expire // The command returns -2 if the key does not exist. ttl := client.TTL(ctx, "key") @@ -2042,7 +2036,6 @@ var _ = Describe("Commands", func() { }) It("should ACL LOG", func() { - err := client.Do(ctx, "acl", "setuser", "test", ">test", "on", "allkeys", "+get").Err() Expect(err).NotTo(HaveOccurred()) @@ -2073,7 +2066,6 @@ var _ = Describe("Commands", func() { limitedLogEntries, err := client.ACLLog(ctx, 2).Result() Expect(err).NotTo(HaveOccurred()) Expect(len(limitedLogEntries)).To(Equal(2)) - }) It("should ACL LOG RESET", func() { @@ -2087,7 +2079,6 @@ var _ = Describe("Commands", func() { Expect(err).NotTo(HaveOccurred()) Expect(len(logEntries)).To(Equal(0)) }) - }) Describe("hashes", func() { @@ -2699,7 +2690,6 @@ var _ = Describe("Commands", func() { Expect(err).NotTo(HaveOccurred()) Expect(key).To(Equal("list2")) Expect(val).To(Equal([]string{"a", "b", "c", "d"})) - }) It("should BLMPopBlocks", func() { @@ -2721,7 +2711,7 @@ var _ = Describe("Commands", func() { case <-done: Fail("BLMPop is not blocked") case <-time.After(time.Second): - //ok + // ok } _, err := client.LPush(ctx, "list_list", "a").Result() @@ -2729,7 +2719,7 @@ var _ = Describe("Commands", func() { select { case <-done: - //ok + // ok case <-time.After(time.Second): Fail("BLMPop is still blocked") } @@ -4184,7 +4174,6 @@ var _ = Describe("Commands", func() { }) It("should ZMPop", func() { - err := client.ZAdd(ctx, "zset", redis.Z{Score: 1, Member: "one"}).Err() Expect(err).NotTo(HaveOccurred()) err = client.ZAdd(ctx, "zset", redis.Z{Score: 2, Member: "two"}).Err() @@ -4256,11 +4245,9 @@ var _ = Describe("Commands", func() { Score: 6, Member: "six", }})) - }) It("should BZMPop", func() { - err := client.ZAdd(ctx, "zset", redis.Z{Score: 1, Member: "one"}).Err() Expect(err).NotTo(HaveOccurred()) err = client.ZAdd(ctx, "zset", redis.Z{Score: 2, Member: "two"}).Err() @@ -4360,7 +4347,7 @@ var _ = Describe("Commands", func() { case <-done: Fail("BZMPop is not blocked") case <-time.After(time.Second): - //ok + // ok } err := client.ZAdd(ctx, "list_list", redis.Z{Score: 1, Member: "one"}).Err() @@ -4368,7 +4355,7 @@ var _ = Describe("Commands", func() { select { case <-done: - //ok + // ok case <-time.After(time.Second): Fail("BZMPop is still blocked") } @@ -6928,7 +6915,6 @@ var _ = Describe("Commands", func() { close(started) }) - }) Describe("SlowLogGet", func() { @@ -6949,7 +6935,6 @@ var _ = Describe("Commands", func() { Expect(len(result)).NotTo(BeZero()) }) }) - }) type numberStruct struct { diff --git a/doctests/lpush_lrange_test.go b/doctests/lpush_lrange_test.go index 64020c915..1e69f4b0a 100644 --- a/doctests/lpush_lrange_test.go +++ b/doctests/lpush_lrange_test.go @@ -5,10 +5,11 @@ package example_commands_test import ( "context" "fmt" + "github.com/redis/go-redis/v9" ) -func ExampleLPushLRange() { +func ExampleClient_LPush_and_lrange() { ctx := context.Background() rdb := redis.NewClient(&redis.Options{ diff --git a/doctests/set_get_test.go b/doctests/set_get_test.go index 792bd4190..ab3a93603 100644 --- a/doctests/set_get_test.go +++ b/doctests/set_get_test.go @@ -5,10 +5,11 @@ package example_commands_test import ( "context" "fmt" + "github.com/redis/go-redis/v9" ) -func ExampleSetGet() { +func ExampleClient_Set_and_get() { ctx := context.Background() rdb := redis.NewClient(&redis.Options{ diff --git a/example/del-keys-without-ttl/main.go b/example/del-keys-without-ttl/main.go index 549d78e21..d2f85d4e8 100644 --- a/example/del-keys-without-ttl/main.go +++ b/example/del-keys-without-ttl/main.go @@ -6,8 +6,9 @@ import ( "sync" "time" - "github.com/redis/go-redis/v9" "go.uber.org/zap" + + "github.com/redis/go-redis/v9" ) func main() { diff --git a/extra/redisotel/metrics.go b/extra/redisotel/metrics.go index 695c7ee3e..fc44a14ca 100644 --- a/extra/redisotel/metrics.go +++ b/extra/redisotel/metrics.go @@ -6,10 +6,11 @@ import ( "net" "time" - "github.com/redis/go-redis/v9" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/metric" + + "github.com/redis/go-redis/v9" ) // InstrumentMetrics starts reporting OpenTelemetry Metrics. diff --git a/extra/redisprometheus/collector.go b/extra/redisprometheus/collector.go index b726ec43a..77c424e89 100644 --- a/extra/redisprometheus/collector.go +++ b/extra/redisprometheus/collector.go @@ -29,12 +29,12 @@ var _ prometheus.Collector = (*Collector)(nil) // The given namespace and subsystem are used to build the fully qualified metric name, // i.e. "{namespace}_{subsystem}_{metric}". // The provided metrics are: -// * pool_hit_total -// * pool_miss_total -// * pool_timeout_total -// * pool_conn_total_current -// * pool_conn_idle_current -// * pool_conn_stale_total +// - pool_hit_total +// - pool_miss_total +// - pool_timeout_total +// - pool_conn_total_current +// - pool_conn_idle_current +// - pool_conn_stale_total func NewCollector(namespace, subsystem string, getter StatGetter) *Collector { return &Collector{ getter: getter, diff --git a/internal/customvet/checks/setval/setval.go b/internal/customvet/checks/setval/setval.go index e629f5f7a..924a9bfc8 100644 --- a/internal/customvet/checks/setval/setval.go +++ b/internal/customvet/checks/setval/setval.go @@ -4,6 +4,7 @@ import ( "go/ast" "go/token" "go/types" + "golang.org/x/tools/go/analysis" ) diff --git a/internal/customvet/checks/setval/setval_test.go b/internal/customvet/checks/setval/setval_test.go index e75647a3d..d93ec45fe 100644 --- a/internal/customvet/checks/setval/setval_test.go +++ b/internal/customvet/checks/setval/setval_test.go @@ -3,8 +3,9 @@ package setval_test import ( "testing" - "github.com/redis/go-redis/internal/customvet/checks/setval" "golang.org/x/tools/go/analysis/analysistest" + + "github.com/redis/go-redis/internal/customvet/checks/setval" ) func Test(t *testing.T) { diff --git a/internal/customvet/main.go b/internal/customvet/main.go index a97a49c9d..6a06ee217 100644 --- a/internal/customvet/main.go +++ b/internal/customvet/main.go @@ -1,8 +1,9 @@ package main import ( - "github.com/redis/go-redis/internal/customvet/checks/setval" "golang.org/x/tools/go/analysis/multichecker" + + "github.com/redis/go-redis/internal/customvet/checks/setval" ) func main() { diff --git a/internal/pool/conn_check.go b/internal/pool/conn_check.go index f04dc1c3b..83190d394 100644 --- a/internal/pool/conn_check.go +++ b/internal/pool/conn_check.go @@ -1,5 +1,4 @@ //go:build linux || darwin || dragonfly || freebsd || netbsd || openbsd || solaris || illumos -// +build linux darwin dragonfly freebsd netbsd openbsd solaris illumos package pool diff --git a/internal/pool/conn_check_dummy.go b/internal/pool/conn_check_dummy.go index 9408446b5..295da1268 100644 --- a/internal/pool/conn_check_dummy.go +++ b/internal/pool/conn_check_dummy.go @@ -1,5 +1,4 @@ //go:build !linux && !darwin && !dragonfly && !freebsd && !netbsd && !openbsd && !solaris && !illumos -// +build !linux,!darwin,!dragonfly,!freebsd,!netbsd,!openbsd,!solaris,!illumos package pool diff --git a/internal/pool/conn_check_test.go b/internal/pool/conn_check_test.go index e5acb9f8f..2ade8a0b9 100644 --- a/internal/pool/conn_check_test.go +++ b/internal/pool/conn_check_test.go @@ -1,5 +1,4 @@ //go:build linux || darwin || dragonfly || freebsd || netbsd || openbsd || solaris || illumos -// +build linux darwin dragonfly freebsd netbsd openbsd solaris illumos package pool diff --git a/internal/util/safe.go b/internal/util/safe.go index 21307110b..8178f86df 100644 --- a/internal/util/safe.go +++ b/internal/util/safe.go @@ -1,5 +1,4 @@ //go:build appengine -// +build appengine package util diff --git a/internal/util/unsafe.go b/internal/util/unsafe.go index daa8d7692..cbcd2cc09 100644 --- a/internal/util/unsafe.go +++ b/internal/util/unsafe.go @@ -1,5 +1,4 @@ //go:build !appengine -// +build !appengine package util diff --git a/main_test.go b/main_test.go index 8e87d76f8..6aaaf1c08 100644 --- a/main_test.go +++ b/main_test.go @@ -36,8 +36,10 @@ const ( sentinelPort3 = "9128" ) -var redisPort = "6380" -var redisAddr = ":" + redisPort +var ( + redisPort = "6380" + redisAddr = ":" + redisPort +) var ( sentinelAddrs = []string{":" + sentinelPort1, ":" + sentinelPort2, ":" + sentinelPort3} diff --git a/options_test.go b/options_test.go index fa9ac6c9e..1db36fdb4 100644 --- a/options_test.go +++ b/options_test.go @@ -1,5 +1,4 @@ //go:build go1.7 -// +build go1.7 package redis diff --git a/probabilistic.go b/probabilistic.go index 969ce8281..61a3460a0 100644 --- a/probabilistic.go +++ b/probabilistic.go @@ -310,6 +310,7 @@ func NewBFInfoCmd(ctx context.Context, args ...interface{}) *BFInfoCmd { func (cmd *BFInfoCmd) SetVal(val BFInfo) { cmd.val = val } + func (cmd *BFInfoCmd) String() string { return cmdString(cmd, cmd.val) } diff --git a/probabilistic_test.go b/probabilistic_test.go index b493abd46..61829c527 100644 --- a/probabilistic_test.go +++ b/probabilistic_test.go @@ -7,6 +7,7 @@ import ( . "github.com/bsm/ginkgo/v2" . "github.com/bsm/gomega" + "github.com/redis/go-redis/v9" ) @@ -159,7 +160,6 @@ var _ = Describe("Probabilistic commands", Label("probabilistic"), func() { Expect(resultAdd2[0]).To(BeFalse()) Expect(resultAdd2[1]).To(BeFalse()) Expect(resultAdd2[2]).To(BeTrue()) - }) It("should BFMExists", Label("bloom", "bfmexists"), func() { @@ -424,7 +424,6 @@ var _ = Describe("Probabilistic commands", Label("probabilistic"), func() { Expect(result[2]).To(BeTrue()) Expect(result[3]).To(BeFalse()) }) - }) Describe("CMS", Label("cms"), func() { @@ -438,7 +437,6 @@ var _ = Describe("Probabilistic commands", Label("probabilistic"), func() { Expect(result[0]).To(BeEquivalentTo(int64(1))) Expect(result[1]).To(BeEquivalentTo(int64(2))) Expect(result[2]).To(BeEquivalentTo(int64(3))) - }) It("should CMSInitByDim and CMSInfo", Label("cms", "cmsinitbydim", "cmsinfo"), func() { @@ -512,9 +510,7 @@ var _ = Describe("Probabilistic commands", Label("probabilistic"), func() { Expect(result[0]).To(BeEquivalentTo(int64(1))) Expect(result[1]).To(BeEquivalentTo(int64(6))) Expect(result[2]).To(BeEquivalentTo(int64(6))) - }) - }) Describe("TopK", Label("topk"), func() { @@ -580,7 +576,6 @@ var _ = Describe("Probabilistic commands", Label("probabilistic"), func() { Expect(resultInfo.Depth).To(BeEquivalentTo(int64(8))) Expect(resultInfo.Decay).To(BeEquivalentTo(0.5)) }) - }) Describe("t-digest", Label("tdigest"), func() { @@ -691,7 +686,6 @@ var _ = Describe("Probabilistic commands", Label("probabilistic"), func() { reset, err := client.TDigestReset(ctx, "tdigest1").Result() Expect(err).NotTo(HaveOccurred()) Expect(reset).To(BeEquivalentTo("OK")) - }) It("should TDigestCreateWithCompression", Label("tdigest", "tcreatewithcompression"), func() { diff --git a/redis_gears.go b/redis_gears.go index 5fafea403..8e6ad874a 100644 --- a/redis_gears.go +++ b/redis_gears.go @@ -88,7 +88,6 @@ func (c cmdable) TFunctionListArgs(ctx context.Context, options *TFunctionListOp } if options.Library != "" { args = append(args, "LIBRARY", options.Library) - } } cmd := NewMapStringInterfaceSliceCmd(ctx, args...) @@ -112,13 +111,11 @@ func (c cmdable) TFCallArgs(ctx context.Context, libName string, funcName string if options != nil { if options.Keys != nil { for _, key := range options.Keys { - args = append(args, key) } } if options.Arguments != nil { for _, key := range options.Arguments { - args = append(args, key) } } @@ -144,13 +141,11 @@ func (c cmdable) TFCallASYNCArgs(ctx context.Context, libName string, funcName s if options != nil { if options.Keys != nil { for _, key := range options.Keys { - args = append(args, key) } } if options.Arguments != nil { for _, key := range options.Arguments { - args = append(args, key) } } diff --git a/redis_gears_test.go b/redis_gears_test.go index 1318615e7..b1117a4dc 100644 --- a/redis_gears_test.go +++ b/redis_gears_test.go @@ -6,6 +6,7 @@ import ( . "github.com/bsm/ginkgo/v2" . "github.com/bsm/gomega" + "github.com/redis/go-redis/v9" ) @@ -48,7 +49,6 @@ var _ = Describe("RedisGears commands", Label("gears"), func() { }) It("should TFunctionLoad, TFunctionLoadArgs and TFunctionDelete ", Label("gears", "tfunctionload"), func() { - resultAdd, err := client.TFunctionLoad(ctx, libCode("lib1")).Result() Expect(err).NotTo(HaveOccurred()) Expect(resultAdd).To(BeEquivalentTo("OK")) @@ -56,7 +56,6 @@ var _ = Describe("RedisGears commands", Label("gears"), func() { resultAdd, err = client.TFunctionLoadArgs(ctx, libCodeWithConfig("lib1"), opt).Result() Expect(err).NotTo(HaveOccurred()) Expect(resultAdd).To(BeEquivalentTo("OK")) - }) It("should TFunctionList", Label("gears", "tfunctionlist"), func() { resultAdd, err := client.TFunctionLoad(ctx, libCode("lib1")).Result() @@ -112,5 +111,4 @@ var _ = Describe("RedisGears commands", Label("gears"), func() { Expect(err).NotTo(HaveOccurred()) Expect(resultAdd).To(BeEquivalentTo("bar")) }) - }) diff --git a/redis_timeseries.go b/redis_timeseries.go index 5ead2fa5f..61cc3a5b6 100644 --- a/redis_timeseries.go +++ b/redis_timeseries.go @@ -209,7 +209,6 @@ func (c cmdable) TSAddWithArgs(ctx context.Context, key string, timestamp interf } if options.ChunkSize != 0 { args = append(args, "CHUNK_SIZE", options.ChunkSize) - } if options.Encoding != "" { args = append(args, "ENCODING", options.Encoding) @@ -251,7 +250,6 @@ func (c cmdable) TSCreateWithArgs(ctx context.Context, key string, options *TSOp } if options.ChunkSize != 0 { args = append(args, "CHUNK_SIZE", options.ChunkSize) - } if options.Encoding != "" { args = append(args, "ENCODING", options.Encoding) @@ -264,7 +262,6 @@ func (c cmdable) TSCreateWithArgs(ctx context.Context, key string, options *TSOp args = append(args, "LABELS") for label, value := range options.Labels { args = append(args, label, value) - } } } @@ -285,7 +282,6 @@ func (c cmdable) TSAlter(ctx context.Context, key string, options *TSAlterOption } if options.ChunkSize != 0 { args = append(args, "CHUNK_SIZE", options.ChunkSize) - } if options.DuplicatePolicy != "" { args = append(args, "DUPLICATE_POLICY", options.DuplicatePolicy) @@ -294,7 +290,6 @@ func (c cmdable) TSAlter(ctx context.Context, key string, options *TSAlterOption args = append(args, "LABELS") for label, value := range options.Labels { args = append(args, label, value) - } } } @@ -352,7 +347,6 @@ func (c cmdable) TSIncrByWithArgs(ctx context.Context, key string, timestamp flo } if options.ChunkSize != 0 { args = append(args, "CHUNK_SIZE", options.ChunkSize) - } if options.Uncompressed { args = append(args, "UNCOMPRESSED") @@ -361,7 +355,6 @@ func (c cmdable) TSIncrByWithArgs(ctx context.Context, key string, timestamp flo args = append(args, "LABELS") for label, value := range options.Labels { args = append(args, label, value) - } } } @@ -394,7 +387,6 @@ func (c cmdable) TSDecrByWithArgs(ctx context.Context, key string, timestamp flo } if options.ChunkSize != 0 { args = append(args, "CHUNK_SIZE", options.ChunkSize) - } if options.Uncompressed { args = append(args, "UNCOMPRESSED") @@ -403,7 +395,6 @@ func (c cmdable) TSDecrByWithArgs(ctx context.Context, key string, timestamp flo args = append(args, "LABELS") for label, value := range options.Labels { args = append(args, label, value) - } } } diff --git a/redis_timeseries_test.go b/redis_timeseries_test.go index 291274de3..29897b54c 100644 --- a/redis_timeseries_test.go +++ b/redis_timeseries_test.go @@ -6,6 +6,7 @@ import ( . "github.com/bsm/ginkgo/v2" . "github.com/bsm/gomega" + "github.com/redis/go-redis/v9" ) @@ -137,7 +138,6 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() { resultGet, err = client.TSGet(ctx, "tsami-1").Result() Expect(err).NotTo(HaveOccurred()) Expect(resultGet.Value).To(BeEquivalentTo(5)) - }) It("should TSAlter", Label("timeseries", "tsalter"), func() { @@ -179,7 +179,6 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() { resultInfo, err = client.TSInfo(ctx, "1").Result() Expect(err).NotTo(HaveOccurred()) Expect(resultInfo["duplicatePolicy"]).To(BeEquivalentTo("min")) - }) It("should TSCreateRule and TSDeleteRule", Label("timeseries", "tscreaterule", "tsdeleterule"), func() { @@ -215,7 +214,6 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() { resultInfo, err := client.TSInfo(ctx, "1").Result() Expect(err).NotTo(HaveOccurred()) Expect(resultInfo["rules"]).To(BeEquivalentTo(map[interface{}]interface{}{})) - }) It("should TSIncrBy, TSIncrByWithArgs, TSDecrBy and TSDecrByWithArgs", Label("timeseries", "tsincrby", "tsdecrby", "tsincrbyWithArgs", "tsdecrbyWithArgs"), func() { @@ -290,7 +288,6 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() { Expect(err).NotTo(HaveOccurred()) Expect(result.Timestamp).To(BeEquivalentTo(2265985)) Expect(result.Value).To(BeEquivalentTo(151)) - }) It("should TSGet Latest", Label("timeseries", "tsgetlatest"), func() { @@ -328,7 +325,6 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() { result, err := client.TSInfo(ctx, "foo").Result() Expect(err).NotTo(HaveOccurred()) Expect(result["firstTimestamp"]).To(BeEquivalentTo(2265985)) - }) It("should TSMAdd", Label("timeseries", "tsmadd"), func() { @@ -346,7 +342,6 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() { result, err := client.TSMAdd(ctx, ktvSlices).Result() Expect(err).NotTo(HaveOccurred()) Expect(result).To(BeEquivalentTo([]int64{1, 2, 3})) - }) It("should TSMGet and TSMGetWithArgs", Label("timeseries", "tsmget", "tsmgetWithArgs"), func() { @@ -397,7 +392,6 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() { result, err = client.TSMGetWithArgs(ctx, []string{"is_compaction=true"}, mgetOpt).Result() Expect(err).NotTo(HaveOccurred()) Expect(result["d"][1]).To(BeEquivalentTo([]interface{}{int64(10), 8.0})) - }) It("should TSQueryIndex", Label("timeseries", "tsqueryindex"), func() { @@ -415,7 +409,6 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() { result, err = client.TSQueryIndex(ctx, []string{"Taste=That"}).Result() Expect(err).NotTo(HaveOccurred()) Expect(len(result)).To(BeEquivalentTo(1)) - }) It("should TSDel and TSRange", Label("timeseries", "tsdel", "tsrange"), func() { @@ -674,7 +667,6 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() { Expect(err).NotTo(HaveOccurred()) Expect(resultRange[0]).To(BeEquivalentTo(redis.TSTimestampValue{Timestamp: 70, Value: 5})) Expect(len(resultRange)).To(BeEquivalentTo(7)) - }) It("should TSMRange and TSMRangeWithArgs", Label("timeseries", "tsmrange", "tsmrangeWithArgs"), func() { @@ -761,7 +753,6 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() { result, err = client.TSMRangeWithArgs(ctx, 0, 10, []string{"team=ny"}, mrangeOpt).Result() Expect(err).NotTo(HaveOccurred()) Expect(result["a"][2]).To(BeEquivalentTo([]interface{}{[]interface{}{int64(0), 5.0}, []interface{}{int64(5), 6.0}})) - }) It("should TSMRangeWithArgs Latest", Label("timeseries", "tsmrangeWithArgs", "tsmrangelatest"), func() { @@ -810,7 +801,6 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() { Expect(err).NotTo(HaveOccurred()) Expect(result["b"][2]).To(BeEquivalentTo([]interface{}{[]interface{}{int64(0), 4.0}, []interface{}{int64(10), 8.0}})) Expect(result["d"][2]).To(BeEquivalentTo([]interface{}{[]interface{}{int64(0), 4.0}, []interface{}{int64(10), 8.0}})) - }) It("should TSMRevRange and TSMRevRangeWithArgs", Label("timeseries", "tsmrevrange", "tsmrevrangeWithArgs"), func() { createOpt := &redis.TSOptions{Labels: map[string]string{"Test": "This", "team": "ny"}} @@ -896,7 +886,6 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() { result, err = client.TSMRevRangeWithArgs(ctx, 0, 10, []string{"team=ny"}, mrangeOpt).Result() Expect(err).NotTo(HaveOccurred()) Expect(result["a"][2]).To(BeEquivalentTo([]interface{}{[]interface{}{int64(1), 10.0}, []interface{}{int64(0), 1.0}})) - }) It("should TSMRevRangeWithArgs Latest", Label("timeseries", "tsmrevrangeWithArgs", "tsmrevrangelatest"), func() { @@ -945,7 +934,5 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() { Expect(err).NotTo(HaveOccurred()) Expect(result["b"][2]).To(BeEquivalentTo([]interface{}{[]interface{}{int64(10), 8.0}, []interface{}{int64(0), 4.0}})) Expect(result["d"][2]).To(BeEquivalentTo([]interface{}{[]interface{}{int64(10), 8.0}, []interface{}{int64(0), 4.0}})) - }) - }) diff --git a/ring.go b/ring.go index 0572ba346..7cf09111b 100644 --- a/ring.go +++ b/ring.go @@ -292,7 +292,6 @@ func (c *ringSharding) SetAddrs(addrs map[string]string) { func (c *ringSharding) newRingShards( addrs map[string]string, existing *ringShards, ) (shards *ringShards, created, unused map[string]*ringShard) { - shards = &ringShards{m: make(map[string]*ringShard, len(addrs))} created = make(map[string]*ringShard) // indexed by addr unused = make(map[string]*ringShard) // indexed by addr