1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-29 17:41:15 +03:00

Fix/normalise pubsubnumsub response

This commit is contained in:
Dimitrij Denissenko
2015-01-25 12:05:19 +00:00
committed by Vladimir Mihailenco
parent 2a81661b34
commit 34855172f2
4 changed files with 75 additions and 6 deletions

View File

@ -229,6 +229,38 @@ func parseStringStringMap(rd *bufio.Reader, n int64) (interface{}, error) {
return m, nil
}
func parseStringIntMap(rd *bufio.Reader, n int64) (interface{}, error) {
m := make(map[string]int64, n/2)
for i := int64(0); i < n; i += 2 {
keyiface, err := parseReply(rd, nil)
if err != nil {
return nil, err
}
key, ok := keyiface.(string)
if !ok {
return nil, fmt.Errorf("got %T, expected string", keyiface)
}
valueiface, err := parseReply(rd, nil)
if err != nil {
return nil, err
}
switch value := valueiface.(type) {
case int64:
m[key] = value
case string:
m[key], err = strconv.ParseInt(value, 10, 64)
if err != nil {
return nil, fmt.Errorf("got %v, expected number", value)
}
default:
return nil, fmt.Errorf("got %T, expected number or string", valueiface)
}
}
return m, nil
}
func parseZSlice(rd *bufio.Reader, n int64) (interface{}, error) {
zz := make([]Z, n/2)
for i := int64(0); i < n; i += 2 {