mirror of https://github.com/go-redis/redis.git
Fix golangci-lint check
This commit is contained in:
parent
e3c1e884eb
commit
02a9c81ef1
|
@ -22,3 +22,5 @@ linters:
|
||||||
- exhaustivestruct
|
- exhaustivestruct
|
||||||
- wrapcheck
|
- wrapcheck
|
||||||
- errorlint
|
- errorlint
|
||||||
|
- cyclop
|
||||||
|
- forcetypeassert
|
||||||
|
|
10
cluster.go
10
cluster.go
|
@ -295,8 +295,9 @@ func (c *clusterNodes) Close() error {
|
||||||
|
|
||||||
func (c *clusterNodes) Addrs() ([]string, error) {
|
func (c *clusterNodes) Addrs() ([]string, error) {
|
||||||
var addrs []string
|
var addrs []string
|
||||||
|
|
||||||
c.mu.RLock()
|
c.mu.RLock()
|
||||||
closed := c.closed
|
closed := c.closed //nolint:ifshort
|
||||||
if !closed {
|
if !closed {
|
||||||
if len(c.activeAddrs) > 0 {
|
if len(c.activeAddrs) > 0 {
|
||||||
addrs = c.activeAddrs
|
addrs = c.activeAddrs
|
||||||
|
@ -649,14 +650,15 @@ func (c *clusterStateHolder) LazyReload() {
|
||||||
|
|
||||||
func (c *clusterStateHolder) Get(ctx context.Context) (*clusterState, error) {
|
func (c *clusterStateHolder) Get(ctx context.Context) (*clusterState, error) {
|
||||||
v := c.state.Load()
|
v := c.state.Load()
|
||||||
if v != nil {
|
if v == nil {
|
||||||
|
return c.Reload(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
state := v.(*clusterState)
|
state := v.(*clusterState)
|
||||||
if time.Since(state.createdAt) > 10*time.Second {
|
if time.Since(state.createdAt) > 10*time.Second {
|
||||||
c.LazyReload()
|
c.LazyReload()
|
||||||
}
|
}
|
||||||
return state, nil
|
return state, nil
|
||||||
}
|
|
||||||
return c.Reload(ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *clusterStateHolder) ReloadOrGet(ctx context.Context) (*clusterState, error) {
|
func (c *clusterStateHolder) ReloadOrGet(ctx context.Context) (*clusterState, error) {
|
||||||
|
|
20
commands.go
20
commands.go
|
@ -1989,12 +1989,10 @@ func (c cmdable) ZIncrBy(ctx context.Context, key string, increment float64, mem
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c cmdable) ZInterStore(ctx context.Context, destination string, store *ZStore) *IntCmd {
|
func (c cmdable) ZInterStore(ctx context.Context, destination string, store *ZStore) *IntCmd {
|
||||||
args := make([]interface{}, 3+len(store.Keys))
|
args := make([]interface{}, 0, 3+len(store.Keys))
|
||||||
args[0] = "zinterstore"
|
args = append(args, "zinterstore", destination, len(store.Keys))
|
||||||
args[1] = destination
|
for _, key := range store.Keys {
|
||||||
args[2] = len(store.Keys)
|
args = append(args, key)
|
||||||
for i, key := range store.Keys {
|
|
||||||
args[3+i] = key
|
|
||||||
}
|
}
|
||||||
if len(store.Weights) > 0 {
|
if len(store.Weights) > 0 {
|
||||||
args = append(args, "weights")
|
args = append(args, "weights")
|
||||||
|
@ -2237,12 +2235,10 @@ func (c cmdable) ZScore(ctx context.Context, key, member string) *FloatCmd {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c cmdable) ZUnionStore(ctx context.Context, dest string, store *ZStore) *IntCmd {
|
func (c cmdable) ZUnionStore(ctx context.Context, dest string, store *ZStore) *IntCmd {
|
||||||
args := make([]interface{}, 3+len(store.Keys))
|
args := make([]interface{}, 0, 3+len(store.Keys))
|
||||||
args[0] = "zunionstore"
|
args = append(args, "zunionstore", dest, len(store.Keys))
|
||||||
args[1] = dest
|
for _, key := range store.Keys {
|
||||||
args[2] = len(store.Keys)
|
args = append(args, key)
|
||||||
for i, key := range store.Keys {
|
|
||||||
args[3+i] = key
|
|
||||||
}
|
}
|
||||||
if len(store.Weights) > 0 {
|
if len(store.Weights) > 0 {
|
||||||
args = append(args, "weights")
|
args = append(args, "weights")
|
||||||
|
|
|
@ -172,8 +172,7 @@ func (p *StickyConnPool) Reset(ctx context.Context) error {
|
||||||
|
|
||||||
func (p *StickyConnPool) badConnError() error {
|
func (p *StickyConnPool) badConnError() error {
|
||||||
if v := p._badConnError.Load(); v != nil {
|
if v := p._badConnError.Load(); v != nil {
|
||||||
err := v.(BadConnError)
|
if err := v.(BadConnError); err.wrapped != nil {
|
||||||
if err.wrapped != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ func (r *Reader) readLine() ([]byte, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
full = append(full, b...)
|
full = append(full, b...) //nolint:makezero
|
||||||
b = full
|
b = full
|
||||||
}
|
}
|
||||||
if len(b) <= 2 || b[len(b)-1] != '\n' || b[len(b)-2] != '\r' {
|
if len(b) <= 2 || b[len(b)-1] != '\n' || b[len(b)-2] != '\r' {
|
||||||
|
|
|
@ -10,7 +10,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Scan parses bytes `b` to `v` with appropriate type.
|
// Scan parses bytes `b` to `v` with appropriate type.
|
||||||
// nolint: gocyclo
|
|
||||||
func Scan(b []byte, v interface{}) error {
|
func Scan(b []byte, v interface{}) error {
|
||||||
switch v := v.(type) {
|
switch v := v.(type) {
|
||||||
case nil:
|
case nil:
|
||||||
|
|
|
@ -118,7 +118,7 @@ func mapKeys(m map[string]struct{}) []string {
|
||||||
i := 0
|
i := 0
|
||||||
for k := range m {
|
for k := range m {
|
||||||
s[i] = k
|
s[i] = k
|
||||||
i++
|
i++ // nolint:wastedassign
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
3
redis.go
3
redis.go
|
@ -305,7 +305,8 @@ func (c *baseClient) withConn(
|
||||||
c.releaseConn(ctx, cn, err)
|
c.releaseConn(ctx, cn, err)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
done := ctx.Done()
|
done := ctx.Done() //nolint:ifshort
|
||||||
|
|
||||||
if done == nil {
|
if done == nil {
|
||||||
err = fn(ctx, cn)
|
err = fn(ctx, cn)
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -625,7 +625,7 @@ func parseSlaveAddrs(addrs []interface{}, keepDisconnected bool) []string {
|
||||||
|
|
||||||
func (c *sentinelFailover) trySwitchMaster(ctx context.Context, addr string) {
|
func (c *sentinelFailover) trySwitchMaster(ctx context.Context, addr string) {
|
||||||
c.mu.RLock()
|
c.mu.RLock()
|
||||||
currentAddr := c._masterAddr
|
currentAddr := c._masterAddr //nolint:ifshort
|
||||||
c.mu.RUnlock()
|
c.mu.RUnlock()
|
||||||
|
|
||||||
if addr == currentAddr {
|
if addr == currentAddr {
|
||||||
|
|
Loading…
Reference in New Issue