1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-28 06:42:00 +03:00

Add SliceCmd.Scan() (hscan pkg) and tests

This commit is contained in:
Kailash Nadh
2021-02-02 13:04:52 +05:30
parent 380ab17274
commit a4144ea98e
4 changed files with 135 additions and 2 deletions

View File

@ -8,6 +8,7 @@ import (
"time"
"github.com/go-redis/redis/v8/internal"
"github.com/go-redis/redis/v8/internal/hscan"
"github.com/go-redis/redis/v8/internal/proto"
"github.com/go-redis/redis/v8/internal/util"
)
@ -371,6 +372,13 @@ func (cmd *SliceCmd) String() string {
return cmdString(cmd, cmd.val)
}
// Scan scans the results from a key-value Redis map result set ([]interface{})
// like HMGET and HGETALL to a destination struct.
// The Redis keys are matched to the struct's field with the `redis` tag.
func (cmd *SliceCmd) Scan(val interface{}) error {
return hscan.Scan(cmd.val, val)
}
func (cmd *SliceCmd) readReply(rd *proto.Reader) error {
v, err := rd.ReadArrayReply(sliceParser)
if err != nil {