From f3ce3362a02e7a9c93951105db6715b885420ca8 Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Thu, 25 Jul 2019 13:53:00 +0300 Subject: [PATCH] Add golangci-lint --- .golangci.yml | 11 + .travis.yml | 3 + Makefile | 1 + bench_test.go | 2 +- cluster.go | 5 +- cluster_test.go | 38 ++-- command.go | 9 +- commands.go | 452 +++++++++++++++++++-------------------- internal/error.go | 7 +- internal/pool/pool.go | 2 +- internal/proto/writer.go | 3 +- main_test.go | 2 +- options.go | 3 +- pipeline.go | 2 +- pubsub.go | 5 +- ring.go | 2 +- script.go | 2 +- sentinel.go | 9 +- 18 files changed, 284 insertions(+), 274 deletions(-) create mode 100644 .golangci.yml diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..df94ddc --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,11 @@ +run: + concurrency: 8 + deadline: 5m + tests: false +linters: + enable-all: true + disable: + - gochecknoglobals + - goconst + - gosec + - maligned diff --git a/.travis.yml b/.travis.yml index 96c9713..a06ac2c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,3 +18,6 @@ env: - GO111MODULE=on go_import_path: github.com/go-redis/redis + +before_install: + - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.17.1 diff --git a/Makefile b/Makefile index 0358028..a2fa54a 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ all: testdeps go vet go get github.com/gordonklaus/ineffassign ineffassign . + golangci-lint run testdeps: testdata/redis/src/redis-server diff --git a/bench_test.go b/bench_test.go index 12cd024..834ba07 100644 --- a/bench_test.go +++ b/bench_test.go @@ -237,7 +237,7 @@ func BenchmarkRingWithContext(b *testing.B) { func newClusterScenario() *clusterScenario { return &clusterScenario{ ports: []string{"8220", "8221", "8222", "8223", "8224", "8225"}, - nodeIds: make([]string, 6), + nodeIDs: make([]string, 6), processes: make(map[string]*redisProcess, 6), clients: make(map[string]*redis.Client, 6), } diff --git a/cluster.go b/cluster.go index 932d3d6..b693fbe 100644 --- a/cluster.go +++ b/cluster.go @@ -307,6 +307,7 @@ func (c *clusterNodes) NextGeneration() uint32 { // GC removes unused nodes. func (c *clusterNodes) GC(generation uint32) { + //nolint:prealloc var collected []*clusterNode c.mu.Lock() for addr, node := range c.allNodes { @@ -651,8 +652,8 @@ type clusterClient struct { opt *ClusterOptions nodes *clusterNodes - state *clusterStateHolder - cmdsInfoCache *cmdsInfoCache + state *clusterStateHolder //nolint:structcheck + cmdsInfoCache *cmdsInfoCache //nolint:structcheck } // ClusterClient is a Redis Cluster client representing a pool of zero diff --git a/cluster_test.go b/cluster_test.go index c8554c9..aa92a81 100644 --- a/cluster_test.go +++ b/cluster_test.go @@ -18,7 +18,7 @@ import ( type clusterScenario struct { ports []string - nodeIds []string + nodeIDs []string processes map[string]*redisProcess clients map[string]*redis.Client } @@ -98,7 +98,7 @@ func startCluster(scenario *clusterScenario) error { scenario.processes[port] = process scenario.clients[port] = client - scenario.nodeIds[pos] = info[:40] + scenario.nodeIDs[pos] = info[:40] } // Meet cluster nodes. @@ -120,12 +120,12 @@ func startCluster(scenario *clusterScenario) error { // Bootstrap slaves. for idx, slave := range scenario.slaves() { - masterId := scenario.nodeIds[idx] + masterID := scenario.nodeIDs[idx] // Wait until master is available err := eventually(func() error { s := slave.ClusterNodes().Val() - wanted := masterId + wanted := masterID if !strings.Contains(s, wanted) { return fmt.Errorf("%q does not contain %q", s, wanted) } @@ -135,7 +135,7 @@ func startCluster(scenario *clusterScenario) error { return err } - err = slave.ClusterReplicate(masterId).Err() + err = slave.ClusterReplicate(masterID).Err() if err != nil { return err } @@ -146,30 +146,30 @@ func startCluster(scenario *clusterScenario) error { Start: 0, End: 4999, Nodes: []redis.ClusterNode{{ - Id: "", + ID: "", Addr: "127.0.0.1:8220", }, { - Id: "", + ID: "", Addr: "127.0.0.1:8223", }}, }, { Start: 5000, End: 9999, Nodes: []redis.ClusterNode{{ - Id: "", + ID: "", Addr: "127.0.0.1:8221", }, { - Id: "", + ID: "", Addr: "127.0.0.1:8224", }}, }, { Start: 10000, End: 16383, Nodes: []redis.ClusterNode{{ - Id: "", + ID: "", Addr: "127.0.0.1:8222", }, { - Id: "", + ID: "", Addr: "127.0.0.1:8225", }}, }} @@ -592,30 +592,30 @@ var _ = Describe("ClusterClient", func() { Start: 0, End: 4999, Nodes: []redis.ClusterNode{{ - Id: "", + ID: "", Addr: "127.0.0.1:8220", }, { - Id: "", + ID: "", Addr: "127.0.0.1:8223", }}, }, { Start: 5000, End: 9999, Nodes: []redis.ClusterNode{{ - Id: "", + ID: "", Addr: "127.0.0.1:8221", }, { - Id: "", + ID: "", Addr: "127.0.0.1:8224", }}, }, { Start: 10000, End: 16383, Nodes: []redis.ClusterNode{{ - Id: "", + ID: "", Addr: "127.0.0.1:8222", }, { - Id: "", + ID: "", Addr: "127.0.0.1:8225", }}, }} @@ -647,7 +647,7 @@ var _ = Describe("ClusterClient", func() { }) It("should CLUSTER COUNT-FAILURE-REPORTS", func() { - n, err := client.ClusterCountFailureReports(cluster.nodeIds[0]).Result() + n, err := client.ClusterCountFailureReports(cluster.nodeIDs[0]).Result() Expect(err).NotTo(HaveOccurred()) Expect(n).To(Equal(int64(0))) }) @@ -665,7 +665,7 @@ var _ = Describe("ClusterClient", func() { }) It("should CLUSTER SLAVES", func() { - nodesList, err := client.ClusterSlaves(cluster.nodeIds[0]).Result() + nodesList, err := client.ClusterSlaves(cluster.nodeIDs[0]).Result() Expect(err).NotTo(HaveOccurred()) Expect(nodesList).Should(ContainElement(ContainSubstring("slave"))) Expect(nodesList).Should(HaveLen(1)) diff --git a/command.go b/command.go index 7b7c353..3418f68 100644 --- a/command.go +++ b/command.go @@ -52,7 +52,7 @@ func writeCmd(wr *proto.Writer, cmds ...Cmder) error { } func cmdString(cmd Cmder, val interface{}) string { - var ss []string + ss := make([]string, 0, len(cmd.Args())) for _, arg := range cmd.Args() { ss = append(ss, fmt.Sprint(arg)) } @@ -996,6 +996,7 @@ func (cmd *XMessageSliceCmd) readReply(rd *proto.Reader) error { func xMessageSliceParser(rd *proto.Reader, n int64) (interface{}, error) { msgs := make([]XMessage, n) for i := 0; i < len(msgs); i++ { + i := i _, err := rd.ReadArrayReply(func(rd *proto.Reader, n int64) (interface{}, error) { id, err := rd.ReadString() if err != nil { @@ -1076,6 +1077,7 @@ func (cmd *XStreamSliceCmd) readReply(rd *proto.Reader) error { _, cmd.err = rd.ReadArrayReply(func(rd *proto.Reader, n int64) (interface{}, error) { cmd.val = make([]XStream, n) for i := 0; i < len(cmd.val); i++ { + i := i _, err := rd.ReadArrayReply(func(rd *proto.Reader, n int64) (interface{}, error) { if n != 2 { return nil, fmt.Errorf("got %d, wanted 2", n) @@ -1441,7 +1443,7 @@ func (cmd *ScanCmd) Iterator() *ScanIterator { //------------------------------------------------------------------------------ type ClusterNode struct { - Id string + ID string Addr string } @@ -1528,7 +1530,7 @@ func (cmd *ClusterSlotsCmd) readReply(rd *proto.Reader) error { if err != nil { return nil, err } - nodes[j].Id = id + nodes[j].ID = id } } @@ -1737,6 +1739,7 @@ func (cmd *GeoPosCmd) readReply(rd *proto.Reader) error { _, cmd.err = rd.ReadArrayReply(func(rd *proto.Reader, n int64) (interface{}, error) { cmd.val = make([]*GeoPos, n) for i := 0; i < len(cmd.val); i++ { + i := i _, err := rd.ReadReply(func(rd *proto.Reader, n int64) (interface{}, error) { longitude, err := rd.ReadFloatReply() if err != nil { diff --git a/commands.go b/commands.go index 26af559..1f07f36 100644 --- a/commands.go +++ b/commands.go @@ -313,25 +313,25 @@ type statefulCmdable func(cmd Cmder) error func (c statefulCmdable) Auth(password string) *StatusCmd { cmd := NewStatusCmd("auth", password) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) Echo(message interface{}) *StringCmd { cmd := NewStringCmd("echo", message) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) Ping() *StatusCmd { cmd := NewStatusCmd("ping") - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) Wait(numSlaves int, timeout time.Duration) *IntCmd { cmd := NewIntCmd("wait", numSlaves, int(timeout/time.Millisecond)) - c(cmd) + _ = c(cmd) return cmd } @@ -341,13 +341,13 @@ func (c cmdable) Quit() *StatusCmd { func (c statefulCmdable) Select(index int) *StatusCmd { cmd := NewStatusCmd("select", index) - c(cmd) + _ = c(cmd) return cmd } func (c statefulCmdable) SwapDB(index1, index2 int) *StatusCmd { cmd := NewStatusCmd("swapdb", index1, index2) - c(cmd) + _ = c(cmd) return cmd } @@ -355,7 +355,7 @@ func (c statefulCmdable) SwapDB(index1, index2 int) *StatusCmd { func (c cmdable) Command() *CommandsInfoCmd { cmd := NewCommandsInfoCmd("command") - c(cmd) + _ = c(cmd) return cmd } @@ -366,7 +366,7 @@ func (c cmdable) Del(keys ...string) *IntCmd { args[1+i] = key } cmd := NewIntCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -377,13 +377,13 @@ func (c cmdable) Unlink(keys ...string) *IntCmd { args[1+i] = key } cmd := NewIntCmd(args...) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) Dump(key string) *StringCmd { cmd := NewStringCmd("dump", key) - c(cmd) + _ = c(cmd) return cmd } @@ -394,25 +394,25 @@ func (c cmdable) Exists(keys ...string) *IntCmd { args[1+i] = key } cmd := NewIntCmd(args...) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) Expire(key string, expiration time.Duration) *BoolCmd { cmd := NewBoolCmd("expire", key, formatSec(expiration)) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ExpireAt(key string, tm time.Time) *BoolCmd { cmd := NewBoolCmd("expireat", key, tm.Unix()) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) Keys(pattern string) *StringSliceCmd { cmd := NewStringSliceCmd("keys", pattern) - c(cmd) + _ = c(cmd) return cmd } @@ -426,43 +426,43 @@ func (c cmdable) Migrate(host, port, key string, db int, timeout time.Duration) formatMs(timeout), ) cmd.setReadTimeout(timeout) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) Move(key string, db int) *BoolCmd { cmd := NewBoolCmd("move", key, db) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ObjectRefCount(key string) *IntCmd { cmd := NewIntCmd("object", "refcount", key) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ObjectEncoding(key string) *StringCmd { cmd := NewStringCmd("object", "encoding", key) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ObjectIdleTime(key string) *DurationCmd { cmd := NewDurationCmd(time.Second, "object", "idletime", key) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) Persist(key string) *BoolCmd { cmd := NewBoolCmd("persist", key) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) PExpire(key string, expiration time.Duration) *BoolCmd { cmd := NewBoolCmd("pexpire", key, formatMs(expiration)) - c(cmd) + _ = c(cmd) return cmd } @@ -472,31 +472,31 @@ func (c cmdable) PExpireAt(key string, tm time.Time) *BoolCmd { key, tm.UnixNano()/int64(time.Millisecond), ) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) PTTL(key string) *DurationCmd { cmd := NewDurationCmd(time.Millisecond, "pttl", key) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) RandomKey() *StringCmd { cmd := NewStringCmd("randomkey") - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) Rename(key, newkey string) *StatusCmd { cmd := NewStatusCmd("rename", key, newkey) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) RenameNX(key, newkey string) *BoolCmd { cmd := NewBoolCmd("renamenx", key, newkey) - c(cmd) + _ = c(cmd) return cmd } @@ -507,7 +507,7 @@ func (c cmdable) Restore(key string, ttl time.Duration, value string) *StatusCmd formatMs(ttl), value, ) - c(cmd) + _ = c(cmd) return cmd } @@ -519,7 +519,7 @@ func (c cmdable) RestoreReplace(key string, ttl time.Duration, value string) *St value, "replace", ) - c(cmd) + _ = c(cmd) return cmd } @@ -553,7 +553,7 @@ func (sort *Sort) args(key string) []interface{} { func (c cmdable) Sort(key string, sort *Sort) *StringSliceCmd { cmd := NewStringSliceCmd(sort.args(key)...) - c(cmd) + _ = c(cmd) return cmd } @@ -563,13 +563,13 @@ func (c cmdable) SortStore(key, store string, sort *Sort) *IntCmd { args = append(args, "store", store) } cmd := NewIntCmd(args...) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) SortInterfaces(key string, sort *Sort) *SliceCmd { cmd := NewSliceCmd(sort.args(key)...) - c(cmd) + _ = c(cmd) return cmd } @@ -580,19 +580,19 @@ func (c cmdable) Touch(keys ...string) *IntCmd { args[i+1] = key } cmd := NewIntCmd(args...) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) TTL(key string) *DurationCmd { cmd := NewDurationCmd(time.Second, "ttl", key) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) Type(key string) *StatusCmd { cmd := NewStatusCmd("type", key) - c(cmd) + _ = c(cmd) return cmd } @@ -605,7 +605,7 @@ func (c cmdable) Scan(cursor uint64, match string, count int64) *ScanCmd { args = append(args, "count", count) } cmd := NewScanCmd(c, args...) - c(cmd) + _ = c(cmd) return cmd } @@ -618,7 +618,7 @@ func (c cmdable) SScan(key string, cursor uint64, match string, count int64) *Sc args = append(args, "count", count) } cmd := NewScanCmd(c, args...) - c(cmd) + _ = c(cmd) return cmd } @@ -631,7 +631,7 @@ func (c cmdable) HScan(key string, cursor uint64, match string, count int64) *Sc args = append(args, "count", count) } cmd := NewScanCmd(c, args...) - c(cmd) + _ = c(cmd) return cmd } @@ -644,7 +644,7 @@ func (c cmdable) ZScan(key string, cursor uint64, match string, count int64) *Sc args = append(args, "count", count) } cmd := NewScanCmd(c, args...) - c(cmd) + _ = c(cmd) return cmd } @@ -652,7 +652,7 @@ func (c cmdable) ZScan(key string, cursor uint64, match string, count int64) *Sc func (c cmdable) Append(key, value string) *IntCmd { cmd := NewIntCmd("append", key, value) - c(cmd) + _ = c(cmd) return cmd } @@ -670,7 +670,7 @@ func (c cmdable) BitCount(key string, bitCount *BitCount) *IntCmd { ) } cmd := NewIntCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -683,7 +683,7 @@ func (c cmdable) bitOp(op, destKey string, keys ...string) *IntCmd { args[3+i] = key } cmd := NewIntCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -719,7 +719,7 @@ func (c cmdable) BitPos(key string, bit int64, pos ...int64) *IntCmd { panic("too many arguments") } cmd := NewIntCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -729,62 +729,62 @@ func (c cmdable) BitField(key string, args ...interface{}) *IntSliceCmd { a = append(a, key) a = append(a, args...) cmd := NewIntSliceCmd(a...) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) Decr(key string) *IntCmd { cmd := NewIntCmd("decr", key) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) DecrBy(key string, decrement int64) *IntCmd { cmd := NewIntCmd("decrby", key, decrement) - c(cmd) + _ = c(cmd) return cmd } // Redis `GET key` command. It returns redis.Nil error when key does not exist. func (c cmdable) Get(key string) *StringCmd { cmd := NewStringCmd("get", key) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) GetBit(key string, offset int64) *IntCmd { cmd := NewIntCmd("getbit", key, offset) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) GetRange(key string, start, end int64) *StringCmd { cmd := NewStringCmd("getrange", key, start, end) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) GetSet(key string, value interface{}) *StringCmd { cmd := NewStringCmd("getset", key, value) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) Incr(key string) *IntCmd { cmd := NewIntCmd("incr", key) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) IncrBy(key string, value int64) *IntCmd { cmd := NewIntCmd("incrby", key, value) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) IncrByFloat(key string, value float64) *FloatCmd { cmd := NewFloatCmd("incrbyfloat", key, value) - c(cmd) + _ = c(cmd) return cmd } @@ -795,7 +795,7 @@ func (c cmdable) MGet(keys ...string) *SliceCmd { args[1+i] = key } cmd := NewSliceCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -804,7 +804,7 @@ func (c cmdable) MSet(pairs ...interface{}) *StatusCmd { args[0] = "mset" args = appendArgs(args, pairs) cmd := NewStatusCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -813,7 +813,7 @@ func (c cmdable) MSetNX(pairs ...interface{}) *BoolCmd { args[0] = "msetnx" args = appendArgs(args, pairs) cmd := NewBoolCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -834,7 +834,7 @@ func (c cmdable) Set(key string, value interface{}, expiration time.Duration) *S } } cmd := NewStatusCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -845,7 +845,7 @@ func (c cmdable) SetBit(key string, offset int64, value int) *IntCmd { offset, value, ) - c(cmd) + _ = c(cmd) return cmd } @@ -864,7 +864,7 @@ func (c cmdable) SetNX(key string, value interface{}, expiration time.Duration) cmd = NewBoolCmd("set", key, value, "ex", formatSec(expiration), "nx") } } - c(cmd) + _ = c(cmd) return cmd } @@ -882,19 +882,19 @@ func (c cmdable) SetXX(key string, value interface{}, expiration time.Duration) cmd = NewBoolCmd("set", key, value, "ex", formatSec(expiration), "xx") } } - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) SetRange(key string, offset int64, value string) *IntCmd { cmd := NewIntCmd("setrange", key, offset, value) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) StrLen(key string) *IntCmd { cmd := NewIntCmd("strlen", key) - c(cmd) + _ = c(cmd) return cmd } @@ -908,49 +908,49 @@ func (c cmdable) HDel(key string, fields ...string) *IntCmd { args[2+i] = field } cmd := NewIntCmd(args...) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) HExists(key, field string) *BoolCmd { cmd := NewBoolCmd("hexists", key, field) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) HGet(key, field string) *StringCmd { cmd := NewStringCmd("hget", key, field) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) HGetAll(key string) *StringStringMapCmd { cmd := NewStringStringMapCmd("hgetall", key) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) HIncrBy(key, field string, incr int64) *IntCmd { cmd := NewIntCmd("hincrby", key, field, incr) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) HIncrByFloat(key, field string, incr float64) *FloatCmd { cmd := NewFloatCmd("hincrbyfloat", key, field, incr) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) HKeys(key string) *StringSliceCmd { cmd := NewStringSliceCmd("hkeys", key) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) HLen(key string) *IntCmd { cmd := NewIntCmd("hlen", key) - c(cmd) + _ = c(cmd) return cmd } @@ -962,7 +962,7 @@ func (c cmdable) HMGet(key string, fields ...string) *SliceCmd { args[2+i] = field } cmd := NewSliceCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -977,25 +977,25 @@ func (c cmdable) HMSet(key string, fields map[string]interface{}) *StatusCmd { i += 2 } cmd := NewStatusCmd(args...) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) HSet(key, field string, value interface{}) *BoolCmd { cmd := NewBoolCmd("hset", key, field, value) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) HSetNX(key, field string, value interface{}) *BoolCmd { cmd := NewBoolCmd("hsetnx", key, field, value) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) HVals(key string) *StringSliceCmd { cmd := NewStringSliceCmd("hvals", key) - c(cmd) + _ = c(cmd) return cmd } @@ -1010,7 +1010,7 @@ func (c cmdable) BLPop(timeout time.Duration, keys ...string) *StringSliceCmd { args[len(args)-1] = formatSec(timeout) cmd := NewStringSliceCmd(args...) cmd.setReadTimeout(timeout) - c(cmd) + _ = c(cmd) return cmd } @@ -1023,7 +1023,7 @@ func (c cmdable) BRPop(timeout time.Duration, keys ...string) *StringSliceCmd { args[len(keys)+1] = formatSec(timeout) cmd := NewStringSliceCmd(args...) cmd.setReadTimeout(timeout) - c(cmd) + _ = c(cmd) return cmd } @@ -1035,43 +1035,43 @@ func (c cmdable) BRPopLPush(source, destination string, timeout time.Duration) * formatSec(timeout), ) cmd.setReadTimeout(timeout) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) LIndex(key string, index int64) *StringCmd { cmd := NewStringCmd("lindex", key, index) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) LInsert(key, op string, pivot, value interface{}) *IntCmd { cmd := NewIntCmd("linsert", key, op, pivot, value) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) LInsertBefore(key string, pivot, value interface{}) *IntCmd { cmd := NewIntCmd("linsert", key, "before", pivot, value) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) LInsertAfter(key string, pivot, value interface{}) *IntCmd { cmd := NewIntCmd("linsert", key, "after", pivot, value) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) LLen(key string) *IntCmd { cmd := NewIntCmd("llen", key) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) LPop(key string) *StringCmd { cmd := NewStringCmd("lpop", key) - c(cmd) + _ = c(cmd) return cmd } @@ -1081,7 +1081,7 @@ func (c cmdable) LPush(key string, values ...interface{}) *IntCmd { args[1] = key args = appendArgs(args, values) cmd := NewIntCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -1091,7 +1091,7 @@ func (c cmdable) LPushX(key string, values ...interface{}) *IntCmd { args[1] = key args = appendArgs(args, values) cmd := NewIntCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -1102,19 +1102,19 @@ func (c cmdable) LRange(key string, start, stop int64) *StringSliceCmd { start, stop, ) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) LRem(key string, count int64, value interface{}) *IntCmd { cmd := NewIntCmd("lrem", key, count, value) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) LSet(key string, index int64, value interface{}) *StatusCmd { cmd := NewStatusCmd("lset", key, index, value) - c(cmd) + _ = c(cmd) return cmd } @@ -1125,19 +1125,19 @@ func (c cmdable) LTrim(key string, start, stop int64) *StatusCmd { start, stop, ) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) RPop(key string) *StringCmd { cmd := NewStringCmd("rpop", key) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) RPopLPush(source, destination string) *StringCmd { cmd := NewStringCmd("rpoplpush", source, destination) - c(cmd) + _ = c(cmd) return cmd } @@ -1147,7 +1147,7 @@ func (c cmdable) RPush(key string, values ...interface{}) *IntCmd { args[1] = key args = appendArgs(args, values) cmd := NewIntCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -1157,7 +1157,7 @@ func (c cmdable) RPushX(key string, values ...interface{}) *IntCmd { args[1] = key args = appendArgs(args, values) cmd := NewIntCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -1169,13 +1169,13 @@ func (c cmdable) SAdd(key string, members ...interface{}) *IntCmd { args[1] = key args = appendArgs(args, members) cmd := NewIntCmd(args...) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) SCard(key string) *IntCmd { cmd := NewIntCmd("scard", key) - c(cmd) + _ = c(cmd) return cmd } @@ -1186,7 +1186,7 @@ func (c cmdable) SDiff(keys ...string) *StringSliceCmd { args[1+i] = key } cmd := NewStringSliceCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -1198,7 +1198,7 @@ func (c cmdable) SDiffStore(destination string, keys ...string) *IntCmd { args[2+i] = key } cmd := NewIntCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -1209,7 +1209,7 @@ func (c cmdable) SInter(keys ...string) *StringSliceCmd { args[1+i] = key } cmd := NewStringSliceCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -1221,61 +1221,61 @@ func (c cmdable) SInterStore(destination string, keys ...string) *IntCmd { args[2+i] = key } cmd := NewIntCmd(args...) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) SIsMember(key string, member interface{}) *BoolCmd { cmd := NewBoolCmd("sismember", key, member) - c(cmd) + _ = c(cmd) return cmd } // Redis `SMEMBERS key` command output as a slice func (c cmdable) SMembers(key string) *StringSliceCmd { cmd := NewStringSliceCmd("smembers", key) - c(cmd) + _ = c(cmd) return cmd } // Redis `SMEMBERS key` command output as a map func (c cmdable) SMembersMap(key string) *StringStructMapCmd { cmd := NewStringStructMapCmd("smembers", key) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) SMove(source, destination string, member interface{}) *BoolCmd { cmd := NewBoolCmd("smove", source, destination, member) - c(cmd) + _ = c(cmd) return cmd } // Redis `SPOP key` command. func (c cmdable) SPop(key string) *StringCmd { cmd := NewStringCmd("spop", key) - c(cmd) + _ = c(cmd) return cmd } // Redis `SPOP key count` command. func (c cmdable) SPopN(key string, count int64) *StringSliceCmd { cmd := NewStringSliceCmd("spop", key, count) - c(cmd) + _ = c(cmd) return cmd } // Redis `SRANDMEMBER key` command. func (c cmdable) SRandMember(key string) *StringCmd { cmd := NewStringCmd("srandmember", key) - c(cmd) + _ = c(cmd) return cmd } // Redis `SRANDMEMBER key count` command. func (c cmdable) SRandMemberN(key string, count int64) *StringSliceCmd { cmd := NewStringSliceCmd("srandmember", key, count) - c(cmd) + _ = c(cmd) return cmd } @@ -1285,7 +1285,7 @@ func (c cmdable) SRem(key string, members ...interface{}) *IntCmd { args[1] = key args = appendArgs(args, members) cmd := NewIntCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -1296,7 +1296,7 @@ func (c cmdable) SUnion(keys ...string) *StringSliceCmd { args[1+i] = key } cmd := NewStringSliceCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -1308,7 +1308,7 @@ func (c cmdable) SUnionStore(destination string, keys ...string) *IntCmd { args[2+i] = key } cmd := NewIntCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -1342,7 +1342,7 @@ func (c cmdable) XAdd(a *XAddArgs) *StringCmd { } cmd := NewStringCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -1352,37 +1352,37 @@ func (c cmdable) XDel(stream string, ids ...string) *IntCmd { args = append(args, id) } cmd := NewIntCmd(args...) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) XLen(stream string) *IntCmd { cmd := NewIntCmd("xlen", stream) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) XRange(stream, start, stop string) *XMessageSliceCmd { cmd := NewXMessageSliceCmd("xrange", stream, start, stop) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) XRangeN(stream, start, stop string, count int64) *XMessageSliceCmd { cmd := NewXMessageSliceCmd("xrange", stream, start, stop, "count", count) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) XRevRange(stream, start, stop string) *XMessageSliceCmd { cmd := NewXMessageSliceCmd("xrevrange", stream, start, stop) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) XRevRangeN(stream, start, stop string, count int64) *XMessageSliceCmd { cmd := NewXMessageSliceCmd("xrevrange", stream, start, stop, "count", count) - c(cmd) + _ = c(cmd) return cmd } @@ -1412,7 +1412,7 @@ func (c cmdable) XRead(a *XReadArgs) *XStreamSliceCmd { if a.Block >= 0 { cmd.setReadTimeout(a.Block) } - c(cmd) + _ = c(cmd) return cmd } @@ -1425,31 +1425,31 @@ func (c cmdable) XReadStreams(streams ...string) *XStreamSliceCmd { func (c cmdable) XGroupCreate(stream, group, start string) *StatusCmd { cmd := NewStatusCmd("xgroup", "create", stream, group, start) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) XGroupCreateMkStream(stream, group, start string) *StatusCmd { cmd := NewStatusCmd("xgroup", "create", stream, group, start, "mkstream") - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) XGroupSetID(stream, group, start string) *StatusCmd { cmd := NewStatusCmd("xgroup", "setid", stream, group, start) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) XGroupDestroy(stream, group string) *IntCmd { cmd := NewIntCmd("xgroup", "destroy", stream, group) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) XGroupDelConsumer(stream, group, consumer string) *IntCmd { cmd := NewIntCmd("xgroup", "delconsumer", stream, group, consumer) - c(cmd) + _ = c(cmd) return cmd } @@ -1483,7 +1483,7 @@ func (c cmdable) XReadGroup(a *XReadGroupArgs) *XStreamSliceCmd { if a.Block >= 0 { cmd.setReadTimeout(a.Block) } - c(cmd) + _ = c(cmd) return cmd } @@ -1493,13 +1493,13 @@ func (c cmdable) XAck(stream, group string, ids ...string) *IntCmd { args = append(args, id) } cmd := NewIntCmd(args...) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) XPending(stream, group string) *XPendingCmd { cmd := NewXPendingCmd("xpending", stream, group) - c(cmd) + _ = c(cmd) return cmd } @@ -1519,7 +1519,7 @@ func (c cmdable) XPendingExt(a *XPendingExtArgs) *XPendingExtCmd { args = append(args, a.Consumer) } cmd := NewXPendingExtCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -1534,7 +1534,7 @@ type XClaimArgs struct { func (c cmdable) XClaim(a *XClaimArgs) *XMessageSliceCmd { args := xClaimArgs(a) cmd := NewXMessageSliceCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -1542,7 +1542,7 @@ func (c cmdable) XClaimJustID(a *XClaimArgs) *StringSliceCmd { args := xClaimArgs(a) args = append(args, "justid") cmd := NewStringSliceCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -1561,13 +1561,13 @@ func xClaimArgs(a *XClaimArgs) []interface{} { func (c cmdable) XTrim(key string, maxLen int64) *IntCmd { cmd := NewIntCmd("xtrim", key, "maxlen", maxLen) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) XTrimApprox(key string, maxLen int64) *IntCmd { cmd := NewIntCmd("xtrim", key, "maxlen", "~", maxLen) - c(cmd) + _ = c(cmd) return cmd } @@ -1602,7 +1602,7 @@ func (c cmdable) BZPopMax(timeout time.Duration, keys ...string) *ZWithKeyCmd { args[len(args)-1] = formatSec(timeout) cmd := NewZWithKeyCmd(args...) cmd.setReadTimeout(timeout) - c(cmd) + _ = c(cmd) return cmd } @@ -1616,7 +1616,7 @@ func (c cmdable) BZPopMin(timeout time.Duration, keys ...string) *ZWithKeyCmd { args[len(args)-1] = formatSec(timeout) cmd := NewZWithKeyCmd(args...) cmd.setReadTimeout(timeout) - c(cmd) + _ = c(cmd) return cmd } @@ -1626,7 +1626,7 @@ func (c cmdable) zAdd(a []interface{}, n int, members ...*Z) *IntCmd { a[n+2*i+1] = m.Member } cmd := NewIntCmd(a...) - c(cmd) + _ = c(cmd) return cmd } @@ -1684,7 +1684,7 @@ func (c cmdable) zIncr(a []interface{}, n int, members ...*Z) *FloatCmd { a[n+2*i+1] = m.Member } cmd := NewFloatCmd(a...) - c(cmd) + _ = c(cmd) return cmd } @@ -1714,25 +1714,25 @@ func (c cmdable) ZIncrXX(key string, member *Z) *FloatCmd { func (c cmdable) ZCard(key string) *IntCmd { cmd := NewIntCmd("zcard", key) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ZCount(key, min, max string) *IntCmd { cmd := NewIntCmd("zcount", key, min, max) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ZLexCount(key, min, max string) *IntCmd { cmd := NewIntCmd("zlexcount", key, min, max) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ZIncrBy(key string, increment float64, member string) *FloatCmd { cmd := NewFloatCmd("zincrby", key, increment, member) - c(cmd) + _ = c(cmd) return cmd } @@ -1754,7 +1754,7 @@ func (c cmdable) ZInterStore(destination string, store *ZStore, keys ...string) args = append(args, "aggregate", store.Aggregate) } cmd := NewIntCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -1774,7 +1774,7 @@ func (c cmdable) ZPopMax(key string, count ...int64) *ZSliceCmd { } cmd := NewZSliceCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -1794,7 +1794,7 @@ func (c cmdable) ZPopMin(key string, count ...int64) *ZSliceCmd { } cmd := NewZSliceCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -1809,7 +1809,7 @@ func (c cmdable) zRange(key string, start, stop int64, withScores bool) *StringS args = append(args, "withscores") } cmd := NewStringSliceCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -1819,7 +1819,7 @@ func (c cmdable) ZRange(key string, start, stop int64) *StringSliceCmd { func (c cmdable) ZRangeWithScores(key string, start, stop int64) *ZSliceCmd { cmd := NewZSliceCmd("zrange", key, start, stop, "withscores") - c(cmd) + _ = c(cmd) return cmd } @@ -1842,7 +1842,7 @@ func (c cmdable) zRangeBy(zcmd, key string, opt *ZRangeBy, withScores bool) *Str ) } cmd := NewStringSliceCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -1865,13 +1865,13 @@ func (c cmdable) ZRangeByScoreWithScores(key string, opt *ZRangeBy) *ZSliceCmd { ) } cmd := NewZSliceCmd(args...) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ZRank(key, member string) *IntCmd { cmd := NewIntCmd("zrank", key, member) - c(cmd) + _ = c(cmd) return cmd } @@ -1881,7 +1881,7 @@ func (c cmdable) ZRem(key string, members ...interface{}) *IntCmd { args[1] = key args = appendArgs(args, members) cmd := NewIntCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -1892,31 +1892,31 @@ func (c cmdable) ZRemRangeByRank(key string, start, stop int64) *IntCmd { start, stop, ) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ZRemRangeByScore(key, min, max string) *IntCmd { cmd := NewIntCmd("zremrangebyscore", key, min, max) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ZRemRangeByLex(key, min, max string) *IntCmd { cmd := NewIntCmd("zremrangebylex", key, min, max) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ZRevRange(key string, start, stop int64) *StringSliceCmd { cmd := NewStringSliceCmd("zrevrange", key, start, stop) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ZRevRangeWithScores(key string, start, stop int64) *ZSliceCmd { cmd := NewZSliceCmd("zrevrange", key, start, stop, "withscores") - c(cmd) + _ = c(cmd) return cmd } @@ -1931,7 +1931,7 @@ func (c cmdable) zRevRangeBy(zcmd, key string, opt *ZRangeBy) *StringSliceCmd { ) } cmd := NewStringSliceCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -1954,19 +1954,19 @@ func (c cmdable) ZRevRangeByScoreWithScores(key string, opt *ZRangeBy) *ZSliceCm ) } cmd := NewZSliceCmd(args...) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ZRevRank(key, member string) *IntCmd { cmd := NewIntCmd("zrevrank", key, member) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ZScore(key, member string) *FloatCmd { cmd := NewFloatCmd("zscore", key, member) - c(cmd) + _ = c(cmd) return cmd } @@ -1989,7 +1989,7 @@ func (c cmdable) ZUnionStore(dest string, store *ZStore, keys ...string) *IntCmd args = append(args, "aggregate", store.Aggregate) } cmd := NewIntCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -2001,7 +2001,7 @@ func (c cmdable) PFAdd(key string, els ...interface{}) *IntCmd { args[1] = key args = appendArgs(args, els) cmd := NewIntCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -2012,7 +2012,7 @@ func (c cmdable) PFCount(keys ...string) *IntCmd { args[1+i] = key } cmd := NewIntCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -2024,7 +2024,7 @@ func (c cmdable) PFMerge(dest string, keys ...string) *StatusCmd { args[2+i] = key } cmd := NewStatusCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -2032,19 +2032,19 @@ func (c cmdable) PFMerge(dest string, keys ...string) *StatusCmd { func (c cmdable) BgRewriteAOF() *StatusCmd { cmd := NewStatusCmd("bgrewriteaof") - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) BgSave() *StatusCmd { cmd := NewStatusCmd("bgsave") - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ClientKill(ipPort string) *StatusCmd { cmd := NewStatusCmd("client", "kill", ipPort) - c(cmd) + _ = c(cmd) return cmd } @@ -2058,75 +2058,75 @@ func (c cmdable) ClientKillByFilter(keys ...string) *IntCmd { args[2+i] = key } cmd := NewIntCmd(args...) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ClientList() *StringCmd { cmd := NewStringCmd("client", "list") - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ClientPause(dur time.Duration) *BoolCmd { cmd := NewBoolCmd("client", "pause", formatMs(dur)) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ClientID() *IntCmd { cmd := NewIntCmd("client", "id") - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ClientUnblock(id int64) *IntCmd { cmd := NewIntCmd("client", "unblock", id) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ClientUnblockWithError(id int64) *IntCmd { cmd := NewIntCmd("client", "unblock", id, "error") - c(cmd) + _ = c(cmd) return cmd } // ClientSetName assigns a name to the connection. func (c statefulCmdable) ClientSetName(name string) *BoolCmd { cmd := NewBoolCmd("client", "setname", name) - c(cmd) + _ = c(cmd) return cmd } // ClientGetName returns the name of the connection. func (c cmdable) ClientGetName() *StringCmd { cmd := NewStringCmd("client", "getname") - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ConfigGet(parameter string) *SliceCmd { cmd := NewSliceCmd("config", "get", parameter) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ConfigResetStat() *StatusCmd { cmd := NewStatusCmd("config", "resetstat") - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ConfigSet(parameter, value string) *StatusCmd { cmd := NewStatusCmd("config", "set", parameter, value) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ConfigRewrite() *StatusCmd { cmd := NewStatusCmd("config", "rewrite") - c(cmd) + _ = c(cmd) return cmd } @@ -2137,19 +2137,19 @@ func (c cmdable) DbSize() *IntCmd { func (c cmdable) DBSize() *IntCmd { cmd := NewIntCmd("dbsize") - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) FlushAll() *StatusCmd { cmd := NewStatusCmd("flushall") - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) FlushAllAsync() *StatusCmd { cmd := NewStatusCmd("flushall", "async") - c(cmd) + _ = c(cmd) return cmd } @@ -2160,13 +2160,13 @@ func (c cmdable) FlushDb() *StatusCmd { func (c cmdable) FlushDB() *StatusCmd { cmd := NewStatusCmd("flushdb") - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) FlushDBAsync() *StatusCmd { cmd := NewStatusCmd("flushdb", "async") - c(cmd) + _ = c(cmd) return cmd } @@ -2176,19 +2176,19 @@ func (c cmdable) Info(section ...string) *StringCmd { args = append(args, section[0]) } cmd := NewStringCmd(args...) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) LastSave() *IntCmd { cmd := NewIntCmd("lastsave") - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) Save() *StatusCmd { cmd := NewStatusCmd("save") - c(cmd) + _ = c(cmd) return cmd } @@ -2200,7 +2200,7 @@ func (c cmdable) shutdown(modifier string) *StatusCmd { args = []interface{}{"shutdown", modifier} } cmd := NewStatusCmd(args...) - c(cmd) + _ = c(cmd) if err := cmd.Err(); err != nil { if err == io.EOF { // Server quit as expected. @@ -2228,7 +2228,7 @@ func (c cmdable) ShutdownNoSave() *StatusCmd { func (c cmdable) SlaveOf(host, port string) *StatusCmd { cmd := NewStatusCmd("slaveof", host, port) - c(cmd) + _ = c(cmd) return cmd } @@ -2242,7 +2242,7 @@ func (c cmdable) Sync() { func (c cmdable) Time() *TimeCmd { cmd := NewTimeCmd("time") - c(cmd) + _ = c(cmd) return cmd } @@ -2258,7 +2258,7 @@ func (c cmdable) Eval(script string, keys []string, args ...interface{}) *Cmd { } cmdArgs = appendArgs(cmdArgs, args) cmd := NewCmd(cmdArgs...) - c(cmd) + _ = c(cmd) return cmd } @@ -2272,7 +2272,7 @@ func (c cmdable) EvalSha(sha1 string, keys []string, args ...interface{}) *Cmd { } cmdArgs = appendArgs(cmdArgs, args) cmd := NewCmd(cmdArgs...) - c(cmd) + _ = c(cmd) return cmd } @@ -2284,25 +2284,25 @@ func (c cmdable) ScriptExists(hashes ...string) *BoolSliceCmd { args[2+i] = hash } cmd := NewBoolSliceCmd(args...) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ScriptFlush() *StatusCmd { cmd := NewStatusCmd("script", "flush") - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ScriptKill() *StatusCmd { cmd := NewStatusCmd("script", "kill") - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ScriptLoad(script string) *StringCmd { cmd := NewStringCmd("script", "load", script) - c(cmd) + _ = c(cmd) return cmd } @@ -2310,7 +2310,7 @@ func (c cmdable) ScriptLoad(script string) *StringCmd { func (c cmdable) DebugObject(key string) *StringCmd { cmd := NewStringCmd("debug", "object", key) - c(cmd) + _ = c(cmd) return cmd } @@ -2319,7 +2319,7 @@ func (c cmdable) DebugObject(key string) *StringCmd { // Publish posts the message to the channel. func (c cmdable) Publish(channel string, message interface{}) *IntCmd { cmd := NewIntCmd("publish", channel, message) - c(cmd) + _ = c(cmd) return cmd } @@ -2329,7 +2329,7 @@ func (c cmdable) PubSubChannels(pattern string) *StringSliceCmd { args = append(args, pattern) } cmd := NewStringSliceCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -2341,13 +2341,13 @@ func (c cmdable) PubSubNumSub(channels ...string) *StringIntMapCmd { args[2+i] = channel } cmd := NewStringIntMapCmd(args...) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) PubSubNumPat() *IntCmd { cmd := NewIntCmd("pubsub", "numpat") - c(cmd) + _ = c(cmd) return cmd } @@ -2355,73 +2355,73 @@ func (c cmdable) PubSubNumPat() *IntCmd { func (c cmdable) ClusterSlots() *ClusterSlotsCmd { cmd := NewClusterSlotsCmd("cluster", "slots") - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ClusterNodes() *StringCmd { cmd := NewStringCmd("cluster", "nodes") - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ClusterMeet(host, port string) *StatusCmd { cmd := NewStatusCmd("cluster", "meet", host, port) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ClusterForget(nodeID string) *StatusCmd { cmd := NewStatusCmd("cluster", "forget", nodeID) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ClusterReplicate(nodeID string) *StatusCmd { cmd := NewStatusCmd("cluster", "replicate", nodeID) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ClusterResetSoft() *StatusCmd { cmd := NewStatusCmd("cluster", "reset", "soft") - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ClusterResetHard() *StatusCmd { cmd := NewStatusCmd("cluster", "reset", "hard") - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ClusterInfo() *StringCmd { cmd := NewStringCmd("cluster", "info") - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ClusterKeySlot(key string) *IntCmd { cmd := NewIntCmd("cluster", "keyslot", key) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ClusterGetKeysInSlot(slot int, count int) *StringSliceCmd { cmd := NewStringSliceCmd("cluster", "getkeysinslot", slot, count) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ClusterCountFailureReports(nodeID string) *IntCmd { cmd := NewIntCmd("cluster", "count-failure-reports", nodeID) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ClusterCountKeysInSlot(slot int) *IntCmd { cmd := NewIntCmd("cluster", "countkeysinslot", slot) - c(cmd) + _ = c(cmd) return cmd } @@ -2433,7 +2433,7 @@ func (c cmdable) ClusterDelSlots(slots ...int) *StatusCmd { args[2+i] = slot } cmd := NewStatusCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -2448,31 +2448,31 @@ func (c cmdable) ClusterDelSlotsRange(min, max int) *StatusCmd { func (c cmdable) ClusterSaveConfig() *StatusCmd { cmd := NewStatusCmd("cluster", "saveconfig") - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ClusterSlaves(nodeID string) *StringSliceCmd { cmd := NewStringSliceCmd("cluster", "slaves", nodeID) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ReadOnly() *StatusCmd { cmd := NewStatusCmd("readonly") - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ReadWrite() *StatusCmd { cmd := NewStatusCmd("readwrite") - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) ClusterFailover() *StatusCmd { cmd := NewStatusCmd("cluster", "failover") - c(cmd) + _ = c(cmd) return cmd } @@ -2484,7 +2484,7 @@ func (c cmdable) ClusterAddSlots(slots ...int) *StatusCmd { args[2+i] = num } cmd := NewStatusCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -2509,31 +2509,31 @@ func (c cmdable) GeoAdd(key string, geoLocation ...*GeoLocation) *IntCmd { args[2+3*i+2] = eachLoc.Name } cmd := NewIntCmd(args...) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) GeoRadius(key string, longitude, latitude float64, query *GeoRadiusQuery) *GeoLocationCmd { cmd := NewGeoLocationCmd(query, "georadius", key, longitude, latitude) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) GeoRadiusRO(key string, longitude, latitude float64, query *GeoRadiusQuery) *GeoLocationCmd { cmd := NewGeoLocationCmd(query, "georadius_ro", key, longitude, latitude) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) GeoRadiusByMember(key, member string, query *GeoRadiusQuery) *GeoLocationCmd { cmd := NewGeoLocationCmd(query, "georadiusbymember", key, member) - c(cmd) + _ = c(cmd) return cmd } func (c cmdable) GeoRadiusByMemberRO(key, member string, query *GeoRadiusQuery) *GeoLocationCmd { cmd := NewGeoLocationCmd(query, "georadiusbymember_ro", key, member) - c(cmd) + _ = c(cmd) return cmd } @@ -2542,7 +2542,7 @@ func (c cmdable) GeoDist(key string, member1, member2, unit string) *FloatCmd { unit = "km" } cmd := NewFloatCmd("geodist", key, member1, member2, unit) - c(cmd) + _ = c(cmd) return cmd } @@ -2554,7 +2554,7 @@ func (c cmdable) GeoHash(key string, members ...string) *StringSliceCmd { args[2+i] = member } cmd := NewStringSliceCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -2566,7 +2566,7 @@ func (c cmdable) GeoPos(key string, members ...string) *GeoPosCmd { args[2+i] = member } cmd := NewGeoPosCmd(args...) - c(cmd) + _ = c(cmd) return cmd } @@ -2581,6 +2581,6 @@ func (c cmdable) MemoryUsage(key string, samples ...int) *IntCmd { args = append(args, "SAMPLES", samples[0]) } cmd := NewIntCmd(args...) - c(cmd) + _ = c(cmd) return cmd } diff --git a/internal/error.go b/internal/error.go index 34f6bd4..f9c9ebb 100644 --- a/internal/error.go +++ b/internal/error.go @@ -64,11 +64,12 @@ func IsMovedError(err error) (moved bool, ask bool, addr string) { } s := err.Error() - if strings.HasPrefix(s, "MOVED ") { + switch { + case strings.HasPrefix(s, "MOVED "): moved = true - } else if strings.HasPrefix(s, "ASK ") { + case strings.HasPrefix(s, "ASK "): ask = true - } else { + default: return } diff --git a/internal/pool/pool.go b/internal/pool/pool.go index 0f730eb..1bcb74c 100644 --- a/internal/pool/pool.go +++ b/internal/pool/pool.go @@ -447,7 +447,7 @@ func (p *ConnPool) ReapStaleConns() (int, error) { p.freeTurn() if cn != nil { - p.closeConn(cn) + _ = p.closeConn(cn) n++ } else { break diff --git a/internal/proto/writer.go b/internal/proto/writer.go index cded347..ab2739e 100644 --- a/internal/proto/writer.go +++ b/internal/proto/writer.go @@ -90,9 +90,8 @@ func (w *Writer) writeArg(v interface{}) error { case bool: if v { return w.int(1) - } else { - return w.int(0) } + return w.int(0) case time.Time: return w.string(v.Format(time.RFC3339)) case encoding.BinaryMarshaler: diff --git a/main_test.go b/main_test.go index 7a7f0be..f51c637 100644 --- a/main_test.go +++ b/main_test.go @@ -45,7 +45,7 @@ var ( var cluster = &clusterScenario{ ports: []string{"8220", "8221", "8222", "8223", "8224", "8225"}, - nodeIds: make([]string, 6), + nodeIDs: make([]string, 6), processes: make(map[string]*redisProcess, 6), clients: make(map[string]*redis.Client, 6), } diff --git a/options.go b/options.go index b4a2d12..4da74b1 100644 --- a/options.go +++ b/options.go @@ -113,9 +113,8 @@ func (opt *Options) init() { } if opt.TLSConfig == nil { return netDialer.Dial(network, addr) - } else { - return tls.DialWithDialer(netDialer, opt.Network, opt.Addr, opt.TLSConfig) } + return tls.DialWithDialer(netDialer, opt.Network, opt.Addr, opt.TLSConfig) } } if opt.PoolSize == 0 { diff --git a/pipeline.go b/pipeline.go index 3c861cd..d5c7fbb 100644 --- a/pipeline.go +++ b/pipeline.go @@ -71,7 +71,7 @@ func (c *Pipeline) Process(cmd Cmder) error { // Close closes the pipeline, releasing any open resources. func (c *Pipeline) Close() error { c.mu.Lock() - c.discard() + _ = c.discard() c.closed = true c.mu.Unlock() return nil diff --git a/pubsub.go b/pubsub.go index 600a694..139169f 100644 --- a/pubsub.go +++ b/pubsub.go @@ -97,10 +97,7 @@ func (c *PubSub) resubscribe(cn *pool.Conn) error { var firstErr error if len(c.channels) > 0 { - err := c._subscribe(cn, "subscribe", mapKeys(c.channels)) - if err != nil && firstErr == nil { - firstErr = err - } + firstErr = c._subscribe(cn, "subscribe", mapKeys(c.channels)) } if len(c.patterns) > 0 { diff --git a/ring.go b/ring.go index df71cc8..2cdb01a 100644 --- a/ring.go +++ b/ring.go @@ -339,7 +339,7 @@ type ring struct { hooks opt *RingOptions shards *ringShards - cmdsInfoCache *cmdsInfoCache + cmdsInfoCache *cmdsInfoCache //nolint:structcheck } // Ring is a Redis client that uses consistent hashing to distribute diff --git a/script.go b/script.go index 09f36d9..88b7d0a 100644 --- a/script.go +++ b/script.go @@ -24,7 +24,7 @@ type Script struct { func NewScript(src string) *Script { h := sha1.New() - io.WriteString(h, src) + _, _ = io.WriteString(h, src) return &Script{ src: src, hash: hex.EncodeToString(h.Sum(nil)), diff --git a/sentinel.go b/sentinel.go index 2fb32e3..0e26da1 100644 --- a/sentinel.go +++ b/sentinel.go @@ -432,15 +432,10 @@ func (c *sentinelFailover) setSentinel(sentinel *SentinelClient) { } func (c *sentinelFailover) closeSentinel() error { - var firstErr error - - err := c.pubsub.Close() - if err != nil && firstErr == nil { - firstErr = err - } + firstErr := c.pubsub.Close() c.pubsub = nil - err = c.sentinel.Close() + err := c.sentinel.Close() if err != nil && firstErr == nil { firstErr = err }