redis-shake工具
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

37 lines
787 B

package client
import "github.com/alibaba/RedisShake/internal/log"
func ArrayString(replyInterface interface{}, err error) []string {
if err != nil {
log.PanicError(err)
}
replyArray := replyInterface.([]interface{})
replyArrayString := make([]string, len(replyArray))
for inx, item := range replyArray {
replyArrayString[inx] = item.(string)
}
return replyArrayString
}
func String(reply interface{}, err error) (string, error) {
if err != nil {
return "", err
}
return reply.(string), err
}
func Int64(reply interface{}, err error) (int64, error) {
if err != nil {
return 0, err
}
switch v := reply.(type) {
case int64:
return v, nil
case int:
return int64(v), nil
default:
log.Panicf("reply type is not int64 or int, type=%T", v)
}
return 0, err
}