Skip to content

Commit d3919ee

Browse files
NotAFlightRiskrueian
authored andcommitted
docs: fix the Receive cleanup and parse-error examples (#182)
Signed-off-by: Iain <iain1970@protonmail.com> Signed-off-by: Rueian <rueiancsie@gmail.com>
1 parent 6b32d4c commit d3919ee

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ Note that `client.Receive()` doesn't unsubscribe channels automatically when it
337337
```go
338338
ctx, cancel := context.WithCancel(context.Background())
339339

340-
ctx = rueidis.WithOnReceiveReturnHook(context.Background(), func(err error, client rueidis.CommandClient) error {
340+
ctx = rueidis.WithOnReceiveReturnHook(ctx, func(err error, client rueidis.CommandClient) error {
341341
if errors.Is(err, context.Canceled) {
342342
// Send UNSUBSCRIBE command to the connection
343343
return client.Do(context.Background(), client.B().Unsubscribe().Channel("news").Build()).Error()
@@ -641,7 +641,7 @@ If an incorrect parser function is chosen, an errParse will be returned. Here's
641641
// Attempt to parse the response. If a parsing error occurs, check if the error is a parse error and handle it.
642642
// Normally, you should fix the code by choosing the correct parser function.
643643
// For instance, use ToString() if the expected response is a string, or ToArray() if the expected response is an array as follows:
644-
if err := client.Do(ctx, client.B().Get().Key("k").Build()).ToArray(); IsParseErr(err) {
644+
if _, err := client.Do(ctx, client.B().Get().Key("k").Build()).ToArray(); rueidis.IsParseErr(err) {
645645
fmt.Println("Parsing error:", err)
646646
}
647647
```

0 commit comments

Comments
 (0)