Skip to content

Commit 63c1456

Browse files
authored
Merge branch 'master' into feature/support-round-robin-replica-selection
2 parents ed161a8 + d54e848 commit 63c1456

39 files changed

+1469
-393
lines changed

.github/actions/run-tests/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ runs:
2525
2626
# Mapping of redis version to redis testing containers
2727
declare -A redis_version_mapping=(
28-
["8.0-M05"]="8.0-M05-pre"
28+
["8.0-RC2"]="8.0-RC2-pre"
2929
["7.4.2"]="rs-7.4.0-v2"
3030
["7.2.7"]="rs-7.2.0-v14"
3131
)

.github/wordlist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Lua
2929
MSSQL
3030
namespace
3131
NoSQL
32+
OpenTelemetry
3233
ORM
3334
Packagist
3435
PhpRedis

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
fail-fast: false
1919
matrix:
2020
redis-version:
21-
- "8.0-M05" # 8.0 milestone 5
21+
- "8.0-RC2" # 8.0 RC2
2222
- "7.4.2" # should use redis stack 7.4
2323
go-version:
2424
- "1.23.x"
@@ -43,7 +43,7 @@ jobs:
4343
4444
# Mapping of redis version to redis testing containers
4545
declare -A redis_version_mapping=(
46-
["8.0-M05"]="8.0-M05-pre"
46+
["8.0-RC2"]="8.0-RC2-pre"
4747
["7.4.2"]="rs-7.4.0-v2"
4848
)
4949
if [[ -v redis_version_mapping[$REDIS_VERSION] ]]; then
@@ -72,7 +72,7 @@ jobs:
7272
fail-fast: false
7373
matrix:
7474
redis-version:
75-
- "8.0-M05" # 8.0 milestone 5
75+
- "8.0-RC2" # 8.0 RC2
7676
- "7.4.2" # should use redis stack 7.4
7777
- "7.2.7" # should redis stack 7.2
7878
go-version:

.github/workflows/golangci-lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
steps:
2222
- uses: actions/checkout@v4
2323
- name: golangci-lint
24-
uses: golangci/golangci-lint-action@v6.5.2
24+
uses: golangci/golangci-lint-action@v7.0.0
2525
with:
26-
verify: false # disable verifying the configuration since golangci is currently introducing breaking changes in the configuration
26+
verify: true
2727

.github/workflows/spellcheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
- name: Checkout
99
uses: actions/checkout@v4
1010
- name: Check Spelling
11-
uses: rojopolis/spellcheck-github-actions@0.47.0
11+
uses: rojopolis/spellcheck-github-actions@0.48.0
1212
with:
1313
config_path: .github/spellcheck-settings.yml
1414
task_name: Markdown

.golangci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
1+
version: "2"
12
run:
23
timeout: 5m
34
tests: false
5+
linters:
6+
settings:
7+
staticcheck:
8+
checks:
9+
- all
10+
# Incorrect or missing package comment.
11+
# https://staticcheck.dev/docs/checks/#ST1000
12+
- -ST1000
13+
# Omit embedded fields from selector expression.
14+
# https://staticcheck.dev/docs/checks/#QF1008
15+
- -QF1008
16+
- -ST1003
17+
exclusions:
18+
generated: lax
19+
presets:
20+
- comments
21+
- common-false-positives
22+
- legacy
23+
- std-error-handling
24+
paths:
25+
- third_party$
26+
- builtin$
27+
- examples$
28+
formatters:
29+
exclusions:
30+
generated: lax
31+
paths:
32+
- third_party$
33+
- builtin$
34+
- examples$

CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,7 @@ The core team regularly looks at pull requests. We will provide
112112
feedback as soon as possible. After receiving our feedback, please respond
113113
within two weeks. After that time, we may close your PR if it isn't
114114
showing any activity.
115+
116+
## Support
117+
118+
Maintainers can provide limited support to contributors on discord: https://discord.gg/W4txy5AeKM

README.md

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@
33
[![build workflow](https://github.com/redis/go-redis/actions/workflows/build.yml/badge.svg)](https://github.com/redis/go-redis/actions)
44
[![PkgGoDev](https://pkg.go.dev/badge/github.com/redis/go-redis/v9)](https://pkg.go.dev/github.com/redis/go-redis/v9?tab=doc)
55
[![Documentation](https://img.shields.io/badge/redis-documentation-informational)](https://redis.uptrace.dev/)
6+
[![Go Report Card](https://goreportcard.com/badge/github.com/redis/go-redis/v9)](https://goreportcard.com/report/github.com/redis/go-redis/v9)
67
[![codecov](https://codecov.io/github/redis/go-redis/graph/badge.svg?token=tsrCZKuSSw)](https://codecov.io/github/redis/go-redis)
7-
[![Chat](https://discordapp.com/api/guilds/752070105847955518/widget.png)](https://discord.gg/rWtp5Aj)
8+
9+
[![Discord](https://img.shields.io/discord/697882427875393627.svg?style=social&logo=discord)](https://discord.gg/W4txy5AeKM)
10+
[![Twitch](https://img.shields.io/twitch/status/redisinc?style=social)](https://www.twitch.tv/redisinc)
11+
[![YouTube](https://img.shields.io/youtube/channel/views/UCD78lHSwYqMlyetR0_P4Vig?style=social)](https://www.youtube.com/redisinc)
12+
[![Twitter](https://img.shields.io/twitter/follow/redisinc?style=social)](https://twitter.com/redisinc)
13+
[![Stack Exchange questions](https://img.shields.io/stackexchange/stackoverflow/t/go-redis?style=social&logo=stackoverflow&label=Stackoverflow)](https://stackoverflow.com/questions/tagged/go-redis)
814

915
> go-redis is the official Redis client library for the Go programming language. It offers a straightforward interface for interacting with Redis servers.
1016
@@ -44,7 +50,7 @@ in the `go.mod` to `go 1.24` in one of the next releases.
4450
## Resources
4551

4652
- [Discussions](https://github.com/redis/go-redis/discussions)
47-
- [Chat](https://discord.gg/rWtp5Aj)
53+
- [Chat](https://discord.gg/W4txy5AeKM)
4854
- [Reference](https://pkg.go.dev/github.com/redis/go-redis/v9)
4955
- [Examples](https://pkg.go.dev/github.com/redis/go-redis/v9#pkg-examples)
5056

@@ -167,6 +173,24 @@ func ExampleClient() *redis.Client {
167173

168174
```
169175

176+
### Instrument with OpenTelemetry
177+
178+
```go
179+
import (
180+
"github.com/redis/go-redis/v9"
181+
"github.com/redis/go-redis/extra/redisotel/v9"
182+
"errors"
183+
)
184+
185+
func main() {
186+
...
187+
rdb := redis.NewClient(&redis.Options{...})
188+
189+
if err := errors.Join(redisotel.InstrumentTracing(rdb), redisotel.InstrumentMetrics(rdb)); err != nil {
190+
log.Fatal(err)
191+
}
192+
```
193+
170194
171195
### Advanced Configuration
172196
@@ -215,9 +239,26 @@ val1 := client.FTSearchWithArgs(ctx, "txt", "foo bar", &redis.FTSearchOptions{})
215239
216240
In the Redis-Search module, **the default dialect is 2**. If needed, you can explicitly specify a different dialect using the appropriate configuration in your queries.
217241
218-
## Contributing
242+
**Important**: Be aware that the query dialect may impact the results returned. If needed, you can revert to a different dialect version by passing the desired dialect in the arguments of the command you want to execute.
243+
For example:
244+
```
245+
res2, err := rdb.FTSearchWithArgs(ctx,
246+
"idx:bicycle",
247+
"@pickup_zone:[CONTAINS $bike]",
248+
&redis.FTSearchOptions{
249+
Params: map[string]interface{}{
250+
"bike": "POINT(-0.1278 51.5074)",
251+
},
252+
DialectVersion: 3,
253+
},
254+
).Result()
255+
```
256+
You can find further details in the [query dialect documentation](https://redis.io/docs/latest/develop/interact/search-and-query/advanced-concepts/dialects/).
219257
220-
Please see [out contributing guidelines](CONTRIBUTING.md) to help us improve this library!
258+
## Contributing
259+
We welcome contributions to the go-redis library! If you have a bug fix, feature request, or improvement, please open an issue or pull request on GitHub.
260+
We appreciate your help in making go-redis better for everyone.
261+
If you are interested in contributing to the go-redis library, please check out our [contributing guidelines](CONTRIBUTING.md) for more information on how to get started.
221262
222263
## Look and feel
223264

command.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,7 +1412,8 @@ func (cmd *MapStringSliceInterfaceCmd) readReply(rd *proto.Reader) (err error) {
14121412

14131413
cmd.val = make(map[string][]interface{})
14141414

1415-
if readType == proto.RespMap {
1415+
switch readType {
1416+
case proto.RespMap:
14161417
n, err := rd.ReadMapLen()
14171418
if err != nil {
14181419
return err
@@ -1435,7 +1436,7 @@ func (cmd *MapStringSliceInterfaceCmd) readReply(rd *proto.Reader) (err error) {
14351436
cmd.val[k][j] = value
14361437
}
14371438
}
1438-
} else if readType == proto.RespArray {
1439+
case proto.RespArray:
14391440
// RESP2 response
14401441
n, err := rd.ReadArrayLen()
14411442
if err != nil {
@@ -3831,7 +3832,8 @@ func (cmd *MapStringStringSliceCmd) readReply(rd *proto.Reader) error {
38313832
}
38323833

38333834
// -----------------------------------------------------------------------
3834-
// MapStringInterfaceCmd represents a command that returns a map of strings to interface{}.
3835+
3836+
// MapMapStringInterfaceCmd represents a command that returns a map of strings to interface{}.
38353837
type MapMapStringInterfaceCmd struct {
38363838
baseCmd
38373839
val map[string]interface{}

commands.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ func appendArg(dst []interface{}, arg interface{}) []interface{} {
8181
return dst
8282
case time.Time, time.Duration, encoding.BinaryMarshaler, net.IP:
8383
return append(dst, arg)
84+
case nil:
85+
return dst
8486
default:
8587
// scan struct field
8688
v := reflect.ValueOf(arg)
@@ -153,6 +155,12 @@ func isEmptyValue(v reflect.Value) bool {
153155
return v.Float() == 0
154156
case reflect.Interface, reflect.Pointer:
155157
return v.IsNil()
158+
case reflect.Struct:
159+
if v.Type() == reflect.TypeOf(time.Time{}) {
160+
return v.IsZero()
161+
}
162+
// Only supports the struct time.Time,
163+
// subsequent iterations will follow the func Scan support decoder.
156164
}
157165
return false
158166
}
@@ -330,7 +338,7 @@ func (info LibraryInfo) Validate() error {
330338
return nil
331339
}
332340

333-
// Hello Set the resp protocol used.
341+
// Hello sets the resp protocol used.
334342
func (c statefulCmdable) Hello(ctx context.Context,
335343
ver int, username, password, clientName string,
336344
) *MapStringInterfaceCmd {

0 commit comments

Comments
 (0)