Skip to content

Commit 674c7b8

Browse files
ndyakovccoVeille
andauthored
chore(go): update go version to 1.21 (#3640)
* chore(go): update go version to 1.21 * chore(aggregators): make aggregators work with 1.21 * fix doctests * address copilot comments * use atomic bool for logic and/or aggregators * Update .github/workflows/build.yml Co-authored-by: ccoVeille <[email protected]> * use stable/oldstable, 1.23 and 1.21 * fix versions in README * add oldstable in wordlist --------- Co-authored-by: ccoVeille <[email protected]>
1 parent 16b55f9 commit 674c7b8

File tree

23 files changed

+329
-45
lines changed

23 files changed

+329
-45
lines changed

.github/wordlist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,4 @@ oauth
7676
entraid
7777
MiB
7878
KiB
79+
oldstable

.github/workflows/build.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ jobs:
2222
- "8.2.x" # Redis CE 8.2
2323
- "8.0.x" # Redis CE 8.0
2424
go-version:
25+
- "1.21.x"
2526
- "1.23.x"
26-
- "1.24.x"
27+
- oldstable
28+
- stable
2729

2830
steps:
2931
- name: Set up ${{ matrix.go-version }}
@@ -78,8 +80,10 @@ jobs:
7880
- "8.2.x" # Redis CE 8.2
7981
- "8.0.x" # Redis CE 8.0
8082
go-version:
83+
- "1.21.x"
8184
- "1.23.x"
82-
- "1.24.x"
85+
- oldstable
86+
- stable
8387

8488
steps:
8589
- name: Checkout code

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@ In `go-redis` we are aiming to support the last three releases of Redis. Current
2121
- [Redis 8.2](https://raw.githubusercontent.com/redis/redis/8.2/00-RELEASENOTES) - using Redis CE 8.2
2222
- [Redis 8.4](https://raw.githubusercontent.com/redis/redis/8.4/00-RELEASENOTES) - using Redis CE 8.4
2323

24-
Although the `go.mod` states it requires at minimum `go 1.18`, our CI is configured to run the tests against all three
25-
versions of Redis and latest two versions of Go ([1.23](https://go.dev/doc/devel/release#go1.23.0),
26-
[1.24](https://go.dev/doc/devel/release#go1.24.0)). We observe that some modules related test may not pass with
24+
Although the `go.mod` states it requires at minimum `go 1.21`, our CI is configured to run the tests against all three
25+
versions of Redis and multiple versions of Go ([1.21](https://go.dev/doc/devel/release#go1.21.0),
26+
[1.23](https://go.dev/doc/devel/release#go1.23.0), oldstable, and stable). We observe that some modules related test may not pass with
2727
Redis Stack 7.2 and some commands are changed with Redis CE 8.0.
2828
Although it is not officially supported, `go-redis/v9` should be able to work with any Redis 7.0+.
29-
Please do refer to the documentation and the tests if you experience any issues. We do plan to update the go version
30-
in the `go.mod` to `go 1.24` in one of the next releases.
29+
Please do refer to the documentation and the tests if you experience any issues.
3130

3231
## How do I Redis?
3332

doctests/timeseries_tut_test.go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,24 @@ package example_commands_test
55
import (
66
"context"
77
"fmt"
8-
"maps"
98
"math"
10-
"slices"
119
"sort"
1210

1311
"github.com/redis/go-redis/v9"
1412
)
1513

1614
// HIDE_END
1715

16+
// mapKeys returns a slice of all keys from the map (Go 1.21 compatible)
17+
// TODO: Once minimum Go version is upgraded to 1.23+, replace with slices.Collect(maps.Keys(m))
18+
func mapKeys[K comparable, V any](m map[K]V) []K {
19+
keys := make([]K, 0, len(m))
20+
for k := range m {
21+
keys = append(keys, k)
22+
}
23+
return keys
24+
}
25+
1826
func ExampleClient_timeseries_create() {
1927
ctx := context.Background()
2028

@@ -417,7 +425,7 @@ func ExampleClient_timeseries_query_multi() {
417425
panic(err)
418426
}
419427

420-
res28Keys := slices.Collect(maps.Keys(res28))
428+
res28Keys := mapKeys(res28)
421429
sort.Strings(res28Keys)
422430

423431
for _, k := range res28Keys {
@@ -457,7 +465,7 @@ func ExampleClient_timeseries_query_multi() {
457465
panic(err)
458466
}
459467

460-
res29Keys := slices.Collect(maps.Keys(res29))
468+
res29Keys := mapKeys(res29)
461469
sort.Strings(res29Keys)
462470

463471
for _, k := range res29Keys {
@@ -505,7 +513,7 @@ func ExampleClient_timeseries_query_multi() {
505513
panic(err)
506514
}
507515

508-
res30Keys := slices.Collect(maps.Keys(res30))
516+
res30Keys := mapKeys(res30)
509517
sort.Strings(res30Keys)
510518

511519
for _, k := range res30Keys {
@@ -550,7 +558,7 @@ func ExampleClient_timeseries_query_multi() {
550558
panic(err)
551559
}
552560

553-
res31Keys := slices.Collect(maps.Keys(res31))
561+
res31Keys := mapKeys(res31)
554562
sort.Strings(res31Keys)
555563

556564
for _, k := range res31Keys {
@@ -857,7 +865,7 @@ func ExampleClient_timeseries_aggmulti() {
857865
panic(err)
858866
}
859867

860-
res44Keys := slices.Collect(maps.Keys(res44))
868+
res44Keys := mapKeys(res44)
861869
sort.Strings(res44Keys)
862870

863871
for _, k := range res44Keys {
@@ -905,7 +913,7 @@ func ExampleClient_timeseries_aggmulti() {
905913
panic(err)
906914
}
907915

908-
res45Keys := slices.Collect(maps.Keys(res45))
916+
res45Keys := mapKeys(res45)
909917
sort.Strings(res45Keys)
910918

911919
for _, k := range res45Keys {

example/cluster-mget/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/redis/go-redis/example/cluster-mget
22

3-
go 1.18
3+
go 1.21
44

55
replace github.com/redis/go-redis/v9 => ../..
66

example/del-keys-without-ttl/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/redis/go-redis/example/del-keys-without-ttl
22

3-
go 1.18
3+
go 1.21
44

55
replace github.com/redis/go-redis/v9 => ../..
66

example/digest-optimistic-locking/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/redis/go-redis/example/digest-optimistic-locking
22

3-
go 1.18
3+
go 1.21
44

55
replace github.com/redis/go-redis/v9 => ../..
66

example/hll/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/redis/go-redis/example/hll
22

3-
go 1.18
3+
go 1.21
44

55
replace github.com/redis/go-redis/v9 => ../..
66

example/hset-struct/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/redis/go-redis/example/scan-struct
22

3-
go 1.18
3+
go 1.21
44

55
replace github.com/redis/go-redis/v9 => ../..
66

example/lua-scripting/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/redis/go-redis/example/lua-scripting
22

3-
go 1.18
3+
go 1.21
44

55
replace github.com/redis/go-redis/v9 => ../..
66

0 commit comments

Comments
 (0)