forked from mirror/redis
Add Cmd.Slice helper to cast to []interface{}
This commit is contained in:
parent
4029656ad5
commit
dfd360572f
12
command.go
12
command.go
|
@ -315,6 +315,18 @@ func (cmd *Cmd) Bool() (bool, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (cmd *Cmd) Slice() ([]interface{}, error) {
|
||||||
|
if cmd.err != nil {
|
||||||
|
return nil, cmd.err
|
||||||
|
}
|
||||||
|
switch val := cmd.val.(type) {
|
||||||
|
case []interface{}:
|
||||||
|
return val, nil
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("redis: unexpected type=%T for Slice", val)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (cmd *Cmd) readReply(rd *proto.Reader) (err error) {
|
func (cmd *Cmd) readReply(rd *proto.Reader) (err error) {
|
||||||
cmd.val, err = rd.ReadReply(sliceParser)
|
cmd.val, err = rd.ReadReply(sliceParser)
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue