mirror of
https://github.com/redis/go-redis.git
synced 2025-06-06 17:40:59 +03:00
migrate golangci-lint config to v2 format (#3354)
* migrate golangci-lint config to v2 format * chore: skip CI on migration [skip ci] * Bump golangci version * Address several golangci-lint/staticcheck warnings * change staticchecks settings
This commit is contained in:
parent
cb2cfb000d
commit
09dc3510a2
4
.github/workflows/golangci-lint.yml
vendored
4
.github/workflows/golangci-lint.yml
vendored
@ -21,7 +21,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: golangci-lint
|
- name: golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v6.5.2
|
uses: golangci/golangci-lint-action@v7.0.0
|
||||||
with:
|
with:
|
||||||
verify: false # disable verifying the configuration since golangci is currently introducing breaking changes in the configuration
|
verify: true
|
||||||
|
|
||||||
|
@ -1,3 +1,34 @@
|
|||||||
|
version: "2"
|
||||||
run:
|
run:
|
||||||
timeout: 5m
|
timeout: 5m
|
||||||
tests: false
|
tests: false
|
||||||
|
linters:
|
||||||
|
settings:
|
||||||
|
staticcheck:
|
||||||
|
checks:
|
||||||
|
- all
|
||||||
|
# Incorrect or missing package comment.
|
||||||
|
# https://staticcheck.dev/docs/checks/#ST1000
|
||||||
|
- -ST1000
|
||||||
|
# Omit embedded fields from selector expression.
|
||||||
|
# https://staticcheck.dev/docs/checks/#QF1008
|
||||||
|
- -QF1008
|
||||||
|
- -ST1003
|
||||||
|
exclusions:
|
||||||
|
generated: lax
|
||||||
|
presets:
|
||||||
|
- comments
|
||||||
|
- common-false-positives
|
||||||
|
- legacy
|
||||||
|
- std-error-handling
|
||||||
|
paths:
|
||||||
|
- third_party$
|
||||||
|
- builtin$
|
||||||
|
- examples$
|
||||||
|
formatters:
|
||||||
|
exclusions:
|
||||||
|
generated: lax
|
||||||
|
paths:
|
||||||
|
- third_party$
|
||||||
|
- builtin$
|
||||||
|
- examples$
|
||||||
|
@ -1412,7 +1412,8 @@ func (cmd *MapStringSliceInterfaceCmd) readReply(rd *proto.Reader) (err error) {
|
|||||||
|
|
||||||
cmd.val = make(map[string][]interface{})
|
cmd.val = make(map[string][]interface{})
|
||||||
|
|
||||||
if readType == proto.RespMap {
|
switch readType {
|
||||||
|
case proto.RespMap:
|
||||||
n, err := rd.ReadMapLen()
|
n, err := rd.ReadMapLen()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -1435,7 +1436,7 @@ func (cmd *MapStringSliceInterfaceCmd) readReply(rd *proto.Reader) (err error) {
|
|||||||
cmd.val[k][j] = value
|
cmd.val[k][j] = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if readType == proto.RespArray {
|
case proto.RespArray:
|
||||||
// RESP2 response
|
// RESP2 response
|
||||||
n, err := rd.ReadArrayLen()
|
n, err := rd.ReadArrayLen()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -19,6 +19,6 @@ require (
|
|||||||
)
|
)
|
||||||
|
|
||||||
retract (
|
retract (
|
||||||
v9.5.3 // This version was accidentally released.
|
|
||||||
v9.7.2 // This version was accidentally released.
|
v9.7.2 // This version was accidentally released.
|
||||||
|
v9.5.3 // This version was accidentally released.
|
||||||
)
|
)
|
||||||
|
@ -16,6 +16,6 @@ require (
|
|||||||
)
|
)
|
||||||
|
|
||||||
retract (
|
retract (
|
||||||
v9.5.3 // This version was accidentally released.
|
|
||||||
v9.7.2 // This version was accidentally released.
|
v9.7.2 // This version was accidentally released.
|
||||||
|
v9.5.3 // This version was accidentally released.
|
||||||
)
|
)
|
||||||
|
@ -24,6 +24,6 @@ require (
|
|||||||
)
|
)
|
||||||
|
|
||||||
retract (
|
retract (
|
||||||
v9.5.3 // This version was accidentally released.
|
|
||||||
v9.7.2 // This version was accidentally released.
|
v9.7.2 // This version was accidentally released.
|
||||||
|
v9.5.3 // This version was accidentally released.
|
||||||
)
|
)
|
||||||
|
@ -23,6 +23,6 @@ require (
|
|||||||
)
|
)
|
||||||
|
|
||||||
retract (
|
retract (
|
||||||
v9.5.3 // This version was accidentally released.
|
|
||||||
v9.7.2 // This version was accidentally released.
|
v9.7.2 // This version was accidentally released.
|
||||||
|
v9.5.3 // This version was accidentally released.
|
||||||
)
|
)
|
||||||
|
@ -214,9 +214,10 @@ func (opt *Options) init() {
|
|||||||
opt.ConnMaxIdleTime = 30 * time.Minute
|
opt.ConnMaxIdleTime = 30 * time.Minute
|
||||||
}
|
}
|
||||||
|
|
||||||
if opt.MaxRetries == -1 {
|
switch opt.MaxRetries {
|
||||||
|
case -1:
|
||||||
opt.MaxRetries = 0
|
opt.MaxRetries = 0
|
||||||
} else if opt.MaxRetries == 0 {
|
case 0:
|
||||||
opt.MaxRetries = 3
|
opt.MaxRetries = 3
|
||||||
}
|
}
|
||||||
switch opt.MinRetryBackoff {
|
switch opt.MinRetryBackoff {
|
||||||
|
@ -111,9 +111,10 @@ type ClusterOptions struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (opt *ClusterOptions) init() {
|
func (opt *ClusterOptions) init() {
|
||||||
if opt.MaxRedirects == -1 {
|
switch opt.MaxRedirects {
|
||||||
|
case -1:
|
||||||
opt.MaxRedirects = 0
|
opt.MaxRedirects = 0
|
||||||
} else if opt.MaxRedirects == 0 {
|
case 0:
|
||||||
opt.MaxRedirects = 3
|
opt.MaxRedirects = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
5
ring.go
5
ring.go
@ -128,9 +128,10 @@ func (opt *RingOptions) init() {
|
|||||||
opt.NewConsistentHash = newRendezvous
|
opt.NewConsistentHash = newRendezvous
|
||||||
}
|
}
|
||||||
|
|
||||||
if opt.MaxRetries == -1 {
|
switch opt.MaxRetries {
|
||||||
|
case -1:
|
||||||
opt.MaxRetries = 0
|
opt.MaxRetries = 0
|
||||||
} else if opt.MaxRetries == 0 {
|
case 0:
|
||||||
opt.MaxRetries = 3
|
opt.MaxRetries = 3
|
||||||
}
|
}
|
||||||
switch opt.MinRetryBackoff {
|
switch opt.MinRetryBackoff {
|
||||||
|
@ -41,7 +41,7 @@ var _ = Describe("Sentinel resolution", func() {
|
|||||||
client := redis.NewFailoverClient(&redis.FailoverOptions{
|
client := redis.NewFailoverClient(&redis.FailoverOptions{
|
||||||
MasterName: sentinelName,
|
MasterName: sentinelName,
|
||||||
SentinelAddrs: sentinelAddrs,
|
SentinelAddrs: sentinelAddrs,
|
||||||
MaxRetries: -1,
|
MaxRetries: -1,
|
||||||
})
|
})
|
||||||
|
|
||||||
err := client.Ping(shortCtx).Err()
|
err := client.Ping(shortCtx).Err()
|
||||||
|
14
universal.go
14
universal.go
@ -259,13 +259,13 @@ var (
|
|||||||
// NewUniversalClient returns a new multi client. The type of the returned client depends
|
// NewUniversalClient returns a new multi client. The type of the returned client depends
|
||||||
// on the following conditions:
|
// on the following conditions:
|
||||||
//
|
//
|
||||||
// 1. If the MasterName option is specified with RouteByLatency, RouteRandomly or IsClusterMode,
|
// 1. If the MasterName option is specified with RouteByLatency, RouteRandomly or IsClusterMode,
|
||||||
// a FailoverClusterClient is returned.
|
// a FailoverClusterClient is returned.
|
||||||
// 2. If the MasterName option is specified without RouteByLatency, RouteRandomly or IsClusterMode,
|
// 2. If the MasterName option is specified without RouteByLatency, RouteRandomly or IsClusterMode,
|
||||||
// a sentinel-backed FailoverClient is returned.
|
// a sentinel-backed FailoverClient is returned.
|
||||||
// 3. If the number of Addrs is two or more, or IsClusterMode option is specified,
|
// 3. If the number of Addrs is two or more, or IsClusterMode option is specified,
|
||||||
// a ClusterClient is returned.
|
// a ClusterClient is returned.
|
||||||
// 4. Otherwise, a single-node Client is returned.
|
// 4. Otherwise, a single-node Client is returned.
|
||||||
func NewUniversalClient(opts *UniversalOptions) UniversalClient {
|
func NewUniversalClient(opts *UniversalOptions) UniversalClient {
|
||||||
switch {
|
switch {
|
||||||
case opts.MasterName != "" && (opts.RouteByLatency || opts.RouteRandomly || opts.IsClusterMode):
|
case opts.MasterName != "" && (opts.RouteByLatency || opts.RouteRandomly || opts.IsClusterMode):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user