forked from mirror/redis
Fix golangci
This commit is contained in:
parent
14c843ef89
commit
38c87c1f84
|
@ -7,9 +7,15 @@ linters:
|
|||
disable:
|
||||
- funlen
|
||||
- gochecknoglobals
|
||||
- gochecknoinits
|
||||
- gocognit
|
||||
- goconst
|
||||
- godox
|
||||
- gosec
|
||||
- maligned
|
||||
- wsl
|
||||
- gomnd
|
||||
- goerr113
|
||||
- exhaustive
|
||||
- gofumpt
|
||||
- nestif
|
||||
|
|
|
@ -20,4 +20,5 @@ env:
|
|||
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.21.0
|
||||
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s --
|
||||
-b $(go env GOPATH)/bin v1.28.3
|
||||
|
|
15
cluster.go
15
cluster.go
|
@ -1655,21 +1655,6 @@ loop:
|
|||
return ss
|
||||
}
|
||||
|
||||
func remove(ss []string, es ...string) []string {
|
||||
if len(es) == 0 {
|
||||
return ss[:0]
|
||||
}
|
||||
for _, e := range es {
|
||||
for i, s := range ss {
|
||||
if s == e {
|
||||
ss = append(ss[:i], ss[i+1:]...)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return ss
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
type cmdsMap struct {
|
||||
|
|
|
@ -304,7 +304,7 @@ func (cmd *Cmd) readReply(rd *proto.Reader) error {
|
|||
return cmd.err
|
||||
}
|
||||
|
||||
// Implements proto.MultiBulkParse
|
||||
// sliceParser implements proto.MultiBulkParse.
|
||||
func sliceParser(rd *proto.Reader, n int64) (interface{}, error) {
|
||||
vals := make([]interface{}, n)
|
||||
for i := 0; i < len(vals); i++ {
|
||||
|
@ -1072,7 +1072,7 @@ func (cmd *XMessageSliceCmd) readReply(rd *proto.Reader) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Implements proto.MultiBulkParse
|
||||
// xMessageSliceParser implements proto.MultiBulkParse.
|
||||
func xMessageSliceParser(rd *proto.Reader, n int64) (interface{}, error) {
|
||||
msgs := make([]XMessage, n)
|
||||
for i := 0; i < len(msgs); i++ {
|
||||
|
@ -1107,7 +1107,7 @@ func xMessageSliceParser(rd *proto.Reader, n int64) (interface{}, error) {
|
|||
return msgs, nil
|
||||
}
|
||||
|
||||
// Implements proto.MultiBulkParse
|
||||
// stringInterfaceMapParser implements proto.MultiBulkParse.
|
||||
func stringInterfaceMapParser(rd *proto.Reader, n int64) (interface{}, error) {
|
||||
m := make(map[string]interface{}, n/2)
|
||||
for i := int64(0); i < n; i += 2 {
|
||||
|
|
|
@ -1315,14 +1315,14 @@ func (c cmdable) SIsMember(ctx context.Context, key string, member interface{})
|
|||
return cmd
|
||||
}
|
||||
|
||||
// Redis `SMEMBERS key` command output as a slice
|
||||
// Redis `SMEMBERS key` command output as a slice.
|
||||
func (c cmdable) SMembers(ctx context.Context, key string) *StringSliceCmd {
|
||||
cmd := NewStringSliceCmd(ctx, "smembers", key)
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// Redis `SMEMBERS key` command output as a map
|
||||
// Redis `SMEMBERS key` command output as a map.
|
||||
func (c cmdable) SMembersMap(ctx context.Context, key string) *StringStructMapCmd {
|
||||
cmd := NewStringStructMapCmd(ctx, "smembers", key)
|
||||
_ = c(ctx, cmd)
|
||||
|
@ -2144,7 +2144,8 @@ func (c cmdable) ClientKill(ctx context.Context, ipPort string) *StatusCmd {
|
|||
}
|
||||
|
||||
// ClientKillByFilter is new style syntax, while the ClientKill is old
|
||||
// CLIENT KILL <option> [value] ... <option> [value]
|
||||
//
|
||||
// CLIENT KILL <option> [value] ... <option> [value]
|
||||
func (c cmdable) ClientKillByFilter(ctx context.Context, keys ...string) *IntCmd {
|
||||
args := make([]interface{}, 2+len(keys))
|
||||
args[0] = "client"
|
||||
|
|
|
@ -6,9 +6,9 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
// Count of write commands performed
|
||||
// WritesCounter is a count of write commands performed.
|
||||
WritesCounter metric.Int64Counter
|
||||
// Count of new connections
|
||||
// NewConnectionsCounter is a count of new connections.
|
||||
NewConnectionsCounter metric.Int64Counter
|
||||
)
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ func (OpenTelemetryHook) BeforeProcess(ctx context.Context, cmd redis.Cmder) (co
|
|||
func (OpenTelemetryHook) AfterProcess(ctx context.Context, cmd redis.Cmder) error {
|
||||
span := trace.SpanFromContext(ctx)
|
||||
if err := cmd.Err(); err != nil {
|
||||
internal.RecordError(ctx, err)
|
||||
_ = internal.RecordError(ctx, err)
|
||||
}
|
||||
span.End()
|
||||
return nil
|
||||
|
@ -90,7 +90,7 @@ func (OpenTelemetryHook) BeforeProcessPipeline(ctx context.Context, cmds []redis
|
|||
func (OpenTelemetryHook) AfterProcessPipeline(ctx context.Context, cmds []redis.Cmder) error {
|
||||
span := trace.SpanFromContext(ctx)
|
||||
if err := cmds[0].Err(); err != nil {
|
||||
internal.RecordError(ctx, err)
|
||||
_ = internal.RecordError(ctx, err)
|
||||
}
|
||||
span.End()
|
||||
return nil
|
||||
|
|
44
result.go
44
result.go
|
@ -2,7 +2,7 @@ package redis
|
|||
|
||||
import "time"
|
||||
|
||||
// NewCmdResult returns a Cmd initialised with val and err for testing
|
||||
// NewCmdResult returns a Cmd initialised with val and err for testing.
|
||||
func NewCmdResult(val interface{}, err error) *Cmd {
|
||||
var cmd Cmd
|
||||
cmd.val = val
|
||||
|
@ -10,7 +10,7 @@ func NewCmdResult(val interface{}, err error) *Cmd {
|
|||
return &cmd
|
||||
}
|
||||
|
||||
// NewSliceResult returns a SliceCmd initialised with val and err for testing
|
||||
// NewSliceResult returns a SliceCmd initialised with val and err for testing.
|
||||
func NewSliceResult(val []interface{}, err error) *SliceCmd {
|
||||
var cmd SliceCmd
|
||||
cmd.val = val
|
||||
|
@ -18,7 +18,7 @@ func NewSliceResult(val []interface{}, err error) *SliceCmd {
|
|||
return &cmd
|
||||
}
|
||||
|
||||
// NewStatusResult returns a StatusCmd initialised with val and err for testing
|
||||
// NewStatusResult returns a StatusCmd initialised with val and err for testing.
|
||||
func NewStatusResult(val string, err error) *StatusCmd {
|
||||
var cmd StatusCmd
|
||||
cmd.val = val
|
||||
|
@ -26,7 +26,7 @@ func NewStatusResult(val string, err error) *StatusCmd {
|
|||
return &cmd
|
||||
}
|
||||
|
||||
// NewIntResult returns an IntCmd initialised with val and err for testing
|
||||
// NewIntResult returns an IntCmd initialised with val and err for testing.
|
||||
func NewIntResult(val int64, err error) *IntCmd {
|
||||
var cmd IntCmd
|
||||
cmd.val = val
|
||||
|
@ -34,7 +34,7 @@ func NewIntResult(val int64, err error) *IntCmd {
|
|||
return &cmd
|
||||
}
|
||||
|
||||
// NewDurationResult returns a DurationCmd initialised with val and err for testing
|
||||
// NewDurationResult returns a DurationCmd initialised with val and err for testing.
|
||||
func NewDurationResult(val time.Duration, err error) *DurationCmd {
|
||||
var cmd DurationCmd
|
||||
cmd.val = val
|
||||
|
@ -42,7 +42,7 @@ func NewDurationResult(val time.Duration, err error) *DurationCmd {
|
|||
return &cmd
|
||||
}
|
||||
|
||||
// NewBoolResult returns a BoolCmd initialised with val and err for testing
|
||||
// NewBoolResult returns a BoolCmd initialised with val and err for testing.
|
||||
func NewBoolResult(val bool, err error) *BoolCmd {
|
||||
var cmd BoolCmd
|
||||
cmd.val = val
|
||||
|
@ -50,7 +50,7 @@ func NewBoolResult(val bool, err error) *BoolCmd {
|
|||
return &cmd
|
||||
}
|
||||
|
||||
// NewStringResult returns a StringCmd initialised with val and err for testing
|
||||
// NewStringResult returns a StringCmd initialised with val and err for testing.
|
||||
func NewStringResult(val string, err error) *StringCmd {
|
||||
var cmd StringCmd
|
||||
cmd.val = val
|
||||
|
@ -58,7 +58,7 @@ func NewStringResult(val string, err error) *StringCmd {
|
|||
return &cmd
|
||||
}
|
||||
|
||||
// NewFloatResult returns a FloatCmd initialised with val and err for testing
|
||||
// NewFloatResult returns a FloatCmd initialised with val and err for testing.
|
||||
func NewFloatResult(val float64, err error) *FloatCmd {
|
||||
var cmd FloatCmd
|
||||
cmd.val = val
|
||||
|
@ -66,7 +66,7 @@ func NewFloatResult(val float64, err error) *FloatCmd {
|
|||
return &cmd
|
||||
}
|
||||
|
||||
// NewStringSliceResult returns a StringSliceCmd initialised with val and err for testing
|
||||
// NewStringSliceResult returns a StringSliceCmd initialised with val and err for testing.
|
||||
func NewStringSliceResult(val []string, err error) *StringSliceCmd {
|
||||
var cmd StringSliceCmd
|
||||
cmd.val = val
|
||||
|
@ -74,7 +74,7 @@ func NewStringSliceResult(val []string, err error) *StringSliceCmd {
|
|||
return &cmd
|
||||
}
|
||||
|
||||
// NewBoolSliceResult returns a BoolSliceCmd initialised with val and err for testing
|
||||
// NewBoolSliceResult returns a BoolSliceCmd initialised with val and err for testing.
|
||||
func NewBoolSliceResult(val []bool, err error) *BoolSliceCmd {
|
||||
var cmd BoolSliceCmd
|
||||
cmd.val = val
|
||||
|
@ -82,7 +82,7 @@ func NewBoolSliceResult(val []bool, err error) *BoolSliceCmd {
|
|||
return &cmd
|
||||
}
|
||||
|
||||
// NewStringStringMapResult returns a StringStringMapCmd initialised with val and err for testing
|
||||
// NewStringStringMapResult returns a StringStringMapCmd initialised with val and err for testing.
|
||||
func NewStringStringMapResult(val map[string]string, err error) *StringStringMapCmd {
|
||||
var cmd StringStringMapCmd
|
||||
cmd.val = val
|
||||
|
@ -90,7 +90,7 @@ func NewStringStringMapResult(val map[string]string, err error) *StringStringMap
|
|||
return &cmd
|
||||
}
|
||||
|
||||
// NewStringIntMapCmdResult returns a StringIntMapCmd initialised with val and err for testing
|
||||
// NewStringIntMapCmdResult returns a StringIntMapCmd initialised with val and err for testing.
|
||||
func NewStringIntMapCmdResult(val map[string]int64, err error) *StringIntMapCmd {
|
||||
var cmd StringIntMapCmd
|
||||
cmd.val = val
|
||||
|
@ -98,7 +98,7 @@ func NewStringIntMapCmdResult(val map[string]int64, err error) *StringIntMapCmd
|
|||
return &cmd
|
||||
}
|
||||
|
||||
// NewTimeCmdResult returns a TimeCmd initialised with val and err for testing
|
||||
// NewTimeCmdResult returns a TimeCmd initialised with val and err for testing.
|
||||
func NewTimeCmdResult(val time.Time, err error) *TimeCmd {
|
||||
var cmd TimeCmd
|
||||
cmd.val = val
|
||||
|
@ -106,7 +106,7 @@ func NewTimeCmdResult(val time.Time, err error) *TimeCmd {
|
|||
return &cmd
|
||||
}
|
||||
|
||||
// NewZSliceCmdResult returns a ZSliceCmd initialised with val and err for testing
|
||||
// NewZSliceCmdResult returns a ZSliceCmd initialised with val and err for testing.
|
||||
func NewZSliceCmdResult(val []Z, err error) *ZSliceCmd {
|
||||
var cmd ZSliceCmd
|
||||
cmd.val = val
|
||||
|
@ -114,7 +114,7 @@ func NewZSliceCmdResult(val []Z, err error) *ZSliceCmd {
|
|||
return &cmd
|
||||
}
|
||||
|
||||
// NewZWithKeyCmdResult returns a NewZWithKeyCmd initialised with val and err for testing
|
||||
// NewZWithKeyCmdResult returns a NewZWithKeyCmd initialised with val and err for testing.
|
||||
func NewZWithKeyCmdResult(val *ZWithKey, err error) *ZWithKeyCmd {
|
||||
var cmd ZWithKeyCmd
|
||||
cmd.val = val
|
||||
|
@ -122,7 +122,7 @@ func NewZWithKeyCmdResult(val *ZWithKey, err error) *ZWithKeyCmd {
|
|||
return &cmd
|
||||
}
|
||||
|
||||
// NewScanCmdResult returns a ScanCmd initialised with val and err for testing
|
||||
// NewScanCmdResult returns a ScanCmd initialised with val and err for testing.
|
||||
func NewScanCmdResult(keys []string, cursor uint64, err error) *ScanCmd {
|
||||
var cmd ScanCmd
|
||||
cmd.page = keys
|
||||
|
@ -131,7 +131,7 @@ func NewScanCmdResult(keys []string, cursor uint64, err error) *ScanCmd {
|
|||
return &cmd
|
||||
}
|
||||
|
||||
// NewClusterSlotsCmdResult returns a ClusterSlotsCmd initialised with val and err for testing
|
||||
// NewClusterSlotsCmdResult returns a ClusterSlotsCmd initialised with val and err for testing.
|
||||
func NewClusterSlotsCmdResult(val []ClusterSlot, err error) *ClusterSlotsCmd {
|
||||
var cmd ClusterSlotsCmd
|
||||
cmd.val = val
|
||||
|
@ -139,7 +139,7 @@ func NewClusterSlotsCmdResult(val []ClusterSlot, err error) *ClusterSlotsCmd {
|
|||
return &cmd
|
||||
}
|
||||
|
||||
// NewGeoLocationCmdResult returns a GeoLocationCmd initialised with val and err for testing
|
||||
// NewGeoLocationCmdResult returns a GeoLocationCmd initialised with val and err for testing.
|
||||
func NewGeoLocationCmdResult(val []GeoLocation, err error) *GeoLocationCmd {
|
||||
var cmd GeoLocationCmd
|
||||
cmd.locations = val
|
||||
|
@ -147,7 +147,7 @@ func NewGeoLocationCmdResult(val []GeoLocation, err error) *GeoLocationCmd {
|
|||
return &cmd
|
||||
}
|
||||
|
||||
// NewGeoPosCmdResult returns a GeoPosCmd initialised with val and err for testing
|
||||
// NewGeoPosCmdResult returns a GeoPosCmd initialised with val and err for testing.
|
||||
func NewGeoPosCmdResult(val []*GeoPos, err error) *GeoPosCmd {
|
||||
var cmd GeoPosCmd
|
||||
cmd.val = val
|
||||
|
@ -155,7 +155,7 @@ func NewGeoPosCmdResult(val []*GeoPos, err error) *GeoPosCmd {
|
|||
return &cmd
|
||||
}
|
||||
|
||||
// NewCommandsInfoCmdResult returns a CommandsInfoCmd initialised with val and err for testing
|
||||
// NewCommandsInfoCmdResult returns a CommandsInfoCmd initialised with val and err for testing.
|
||||
func NewCommandsInfoCmdResult(val map[string]*CommandInfo, err error) *CommandsInfoCmd {
|
||||
var cmd CommandsInfoCmd
|
||||
cmd.val = val
|
||||
|
@ -163,7 +163,7 @@ func NewCommandsInfoCmdResult(val map[string]*CommandInfo, err error) *CommandsI
|
|||
return &cmd
|
||||
}
|
||||
|
||||
// NewXMessageSliceCmdResult returns a XMessageSliceCmd initialised with val and err for testing
|
||||
// NewXMessageSliceCmdResult returns a XMessageSliceCmd initialised with val and err for testing.
|
||||
func NewXMessageSliceCmdResult(val []XMessage, err error) *XMessageSliceCmd {
|
||||
var cmd XMessageSliceCmd
|
||||
cmd.val = val
|
||||
|
@ -171,7 +171,7 @@ func NewXMessageSliceCmdResult(val []XMessage, err error) *XMessageSliceCmd {
|
|||
return &cmd
|
||||
}
|
||||
|
||||
// NewXStreamSliceCmdResult returns a XStreamSliceCmd initialised with val and err for testing
|
||||
// NewXStreamSliceCmdResult returns a XStreamSliceCmd initialised with val and err for testing.
|
||||
func NewXStreamSliceCmdResult(val []XStream, err error) *XStreamSliceCmd {
|
||||
var cmd XStreamSliceCmd
|
||||
cmd.val = val
|
||||
|
|
Loading…
Reference in New Issue