Skip to content

Commit 011802a

Browse files
committed
upgrade go, golangci-lint, linting
1 parent 37df8a9 commit 011802a

File tree

7 files changed

+74
-55
lines changed

7 files changed

+74
-55
lines changed

.github/workflows/go_test.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,17 @@ jobs:
1212
strategy:
1313
matrix:
1414
go-version:
15-
- "1.20"
15+
- "1.23"
16+
- "1.24"
1617
name: lint and test
1718
runs-on: ubuntu-latest
1819
steps:
1920
- name: Checkout code
2021
uses: actions/checkout@v4
2122
- name: golangci-lint
22-
uses: golangci/golangci-lint-action@v7.0.0
23+
uses: golangci/golangci-lint-action@v8.0.0
2324
with:
24-
version: v1.51.2
25+
version: v2.1.5
2526
- name: Install Go
2627
uses: actions/setup-go@v5
2728
with:

.golangci.yaml

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,51 @@
1+
version: "2"
12
run:
2-
timeout: 5m
33
issues-exit-code: 1
44
tests: true
5-
skip-dirs:
6-
- local
7-
8-
issues:
9-
max-same-issues: 100
10-
exclude-rules:
11-
- path: _test\.go
12-
linters:
13-
- bodyclose
14-
- errcheck
15-
- gosec
16-
5+
output:
6+
formats:
7+
text:
8+
path: stdout
9+
print-linter-name: true
10+
print-issued-lines: true
11+
path-prefix: ""
1712
linters:
1813
enable:
1914
- bodyclose
20-
- exportloopref
21-
- gofumpt
22-
- goimports
23-
- gosec
24-
- gosimple
25-
- govet
26-
- ineffassign
15+
- copyloopvar
2716
- misspell
2817
- revive
29-
- staticcheck
30-
- typecheck
31-
- unused
3218
- whitespace
33-
34-
output:
35-
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
36-
format: colored-line-number
37-
# print lines of code with issue, default is true
38-
print-issued-lines: true
39-
# print linter name in the end of issue text, default is true
40-
print-linter-name: true
41-
# make issues output unique by line, default is true
42-
uniq-by-line: true
43-
# add a prefix to the output file references; default is no prefix
44-
path-prefix: ""
45-
# sorts results by: filepath, line and column
46-
sort-results: true
47-
48-
linters-settings:
49-
golint:
50-
min-confidence: 0.8
51-
52-
fix: true
19+
exclusions:
20+
generated: lax
21+
presets:
22+
- common-false-positives
23+
- legacy
24+
- std-error-handling
25+
rules:
26+
- linters:
27+
- revive
28+
path: example_test.go
29+
text: seems to be unused
30+
- linters:
31+
- revive
32+
text: package-comments
33+
paths:
34+
- local
35+
- third_party$
36+
- builtin$
37+
- examples$
38+
issues:
39+
max-same-issues: 100
40+
fix: true
41+
formatters:
42+
enable:
43+
- gofumpt
44+
- goimports
45+
exclusions:
46+
generated: lax
47+
paths:
48+
- local
49+
- third_party$
50+
- builtin$
51+
- examples$

go.mod

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
module github.com/go-co-op/gocron-redis-lock/v2
22

3-
go 1.22
4-
toolchain go1.24.1
3+
go 1.23.0
4+
5+
toolchain go1.24.2
56

67
require (
78
github.com/go-co-op/gocron/v2 v2.16.1
89
github.com/go-redsync/redsync/v4 v4.13.0
9-
github.com/redis/go-redis/v9 v9.7.3
10+
github.com/redis/go-redis/v9 v9.8.0
1011
github.com/stretchr/testify v1.10.0
1112
github.com/testcontainers/testcontainers-go/modules/redis v0.37.0
1213
)
@@ -16,7 +17,7 @@ require (
1617
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
1718
github.com/Microsoft/go-winio v0.6.2 // indirect
1819
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
19-
github.com/cespare/xxhash/v2 v2.2.0 // indirect
20+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
2021
github.com/containerd/log v0.1.0 // indirect
2122
github.com/containerd/platforms v0.2.1 // indirect
2223
github.com/cpuguy83/dockercfg v0.3.2 // indirect
@@ -65,9 +66,9 @@ require (
6566
go.opentelemetry.io/otel v1.35.0 // indirect
6667
go.opentelemetry.io/otel/metric v1.35.0 // indirect
6768
go.opentelemetry.io/otel/trace v1.35.0 // indirect
68-
golang.org/x/crypto v0.37.0 // indirect
69-
golang.org/x/sync v0.7.0 // indirect
70-
golang.org/x/sys v0.32.0 // indirect
69+
golang.org/x/crypto v0.38.0 // indirect
70+
golang.org/x/sync v0.14.0 // indirect
71+
golang.org/x/sys v0.33.0 // indirect
7172
google.golang.org/protobuf v1.36.1 // indirect
7273
gopkg.in/yaml.v3 v3.0.1 // indirect
7374
)

go.sum

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqy
1414
github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
1515
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
1616
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
17+
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
18+
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
1719
github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
1820
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
1921
github.com/containerd/platforms v0.2.1 h1:zvwtM3rz2YHPQsF2CHYM8+KtB5dvhISiXh5ZpSBQv6A=
@@ -114,6 +116,8 @@ github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF
114116
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
115117
github.com/redis/go-redis/v9 v9.7.3 h1:YpPyAayJV+XErNsatSElgRZZVCwXX9QzkKYNvO7x0wM=
116118
github.com/redis/go-redis/v9 v9.7.3/go.mod h1:bGUrSggJ9X9GUmZpZNEOQKaANxSGgOEBRltRTZHSvrA=
119+
github.com/redis/go-redis/v9 v9.8.0 h1:q3nRvjrlge/6UD7eTu/DSg2uYiU2mCL0G/uzBWqhicI=
120+
github.com/redis/go-redis/v9 v9.8.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw=
117121
github.com/redis/rueidis v1.0.19 h1:s65oWtotzlIFN8eMPhyYwxlwLR1lUdhza2KtWprKYSo=
118122
github.com/redis/rueidis v1.0.19/go.mod h1:8B+r5wdnjwK3lTFml5VtxjzGOQAC+5UmujoD12pDrEo=
119123
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
@@ -169,6 +173,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
169173
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
170174
golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE=
171175
golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc=
176+
golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8=
177+
golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw=
172178
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
173179
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
174180
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
@@ -182,6 +188,8 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ
182188
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
183189
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
184190
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
191+
golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ=
192+
golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
185193
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
186194
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
187195
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -193,12 +201,16 @@ golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
193201
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
194202
golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20=
195203
golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
204+
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
205+
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
196206
golang.org/x/term v0.31.0 h1:erwDkOK1Msy6offm1mOgvspSkslFnIGsFnxOKoufg3o=
197207
golang.org/x/term v0.31.0/go.mod h1:R4BeIy7D95HzImkxGkTW1UQTtP54tio2RyHz7PwK0aw=
208+
golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg=
198209
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
199210
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
200211
golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0=
201212
golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU=
213+
golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4=
202214
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 h1:vVKdlvoWBphwdxWKrFZEuM0kGgGLxUOYcY4U/2Vjg44=
203215
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
204216
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

options.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ import (
66
"github.com/go-redsync/redsync/v4"
77
)
88

9+
// LockerOption defines a function type that can be implemented to add options to the Locker
910
type LockerOption func(*redisLocker)
1011

12+
// WithAutoExtendDuration sets the duration for auto extending the lock.
1113
func WithAutoExtendDuration(duration time.Duration) LockerOption {
1214
return func(locker *redisLocker) {
1315
locker.autoExtendDuration = duration

redislock.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ func NewRedisLockerAlways(r redis.UniversalClient, options ...redsync.Option) (g
4343
return newLocker(r, options...), r.Ping(context.Background()).Err()
4444
}
4545

46+
// NewRedisLockerWithOptions provides an implementation of the Locker interface using
47+
// redis for storage, with options to configure the locker.
4648
func NewRedisLockerWithOptions(r redis.UniversalClient, options ...LockerOption) (gocron.Locker, error) {
4749
if err := r.Ping(context.Background()).Err(); err != nil {
4850
return nil, fmt.Errorf("%s: %w", ErrFailedToConnectToRedis, err)

redislock_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ import (
1313
testcontainersredis "github.com/testcontainers/testcontainers-go/modules/redis"
1414
)
1515

16+
const imageName = "redis:7"
17+
1618
func TestEnableDistributedLocking(t *testing.T) {
1719
ctx := context.Background()
18-
redisContainer, err := testcontainersredis.RunContainer(ctx)
20+
redisContainer, err := testcontainersredis.Run(ctx, imageName)
1921
require.NoError(t, err)
2022
t.Cleanup(func() {
2123
if err := redisContainer.Terminate(ctx); err != nil {
@@ -70,7 +72,7 @@ func TestEnableDistributedLocking(t *testing.T) {
7072

7173
func TestAutoExtend(t *testing.T) {
7274
ctx := context.Background()
73-
redisContainer, err := testcontainersredis.RunContainer(ctx)
75+
redisContainer, err := testcontainersredis.Run(ctx, imageName)
7476
require.NoError(t, err)
7577
t.Cleanup(func() {
7678
if err := redisContainer.Terminate(ctx); err != nil {

0 commit comments

Comments
 (0)