Compare commits

...

1 Commits

Author SHA1 Message Date
Vladimir Mihailenco dfd360572f Add Cmd.Slice helper to cast to []interface{} 2021-08-13 10:17:44 +03:00
1 changed files with 12 additions and 0 deletions

View File

@ -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) {
cmd.val, err = rd.ReadReply(sliceParser)
return err