mirror of
https://github.com/redis/go-redis.git
synced 2025-07-28 06:42:00 +03:00
Fix all examples in readme. Req now implements Stringer interface for debugging purposes.
This commit is contained in:
12
req.go
12
req.go
@ -1,7 +1,9 @@
|
||||
package redis
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Req interface {
|
||||
@ -64,6 +66,16 @@ func (r *BaseReq) ParseReply(rd reader) (interface{}, error) {
|
||||
return parseReply(rd)
|
||||
}
|
||||
|
||||
func (r *BaseReq) String() string {
|
||||
args := strings.Join(r.args, " ")
|
||||
if r.err != nil {
|
||||
return args + ": " + r.err.Error()
|
||||
} else if r.val != nil {
|
||||
return args + ": " + fmt.Sprint(r.val)
|
||||
}
|
||||
return args
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
type IfaceReq struct {
|
||||
|
Reference in New Issue
Block a user