The current repo belongs to Closed status, and some functions are restricted. For details, please refer to the description of repo status
1 Star 1 Fork 0

仓库镜像/go-redis-redis
Closed

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
proto.go 1.83 KB
Copy Edit Raw Blame History
package proto
import (
"encoding"
"fmt"
"strconv"
"gopkg.in/redis.v5/internal"
)
func Scan(s string, v interface{}) error {
switch v := v.(type) {
case nil:
return internal.RedisError("redis: Scan(nil)")
case *string:
*v = s
return nil
case *[]byte:
*v = []byte(s)
return nil
case *int:
var err error
*v, err = strconv.Atoi(s)
return err
case *int8:
n, err := strconv.ParseInt(s, 10, 8)
if err != nil {
return err
}
*v = int8(n)
return nil
case *int16:
n, err := strconv.ParseInt(s, 10, 16)
if err != nil {
return err
}
*v = int16(n)
return nil
case *int32:
n, err := strconv.ParseInt(s, 10, 32)
if err != nil {
return err
}
*v = int32(n)
return nil
case *int64:
n, err := strconv.ParseInt(s, 10, 64)
if err != nil {
return err
}
*v = n
return nil
case *uint:
n, err := strconv.ParseUint(s, 10, 64)
if err != nil {
return err
}
*v = uint(n)
return nil
case *uint8:
n, err := strconv.ParseUint(s, 10, 8)
if err != nil {
return err
}
*v = uint8(n)
return nil
case *uint16:
n, err := strconv.ParseUint(s, 10, 16)
if err != nil {
return err
}
*v = uint16(n)
return nil
case *uint32:
n, err := strconv.ParseUint(s, 10, 32)
if err != nil {
return err
}
*v = uint32(n)
return nil
case *uint64:
n, err := strconv.ParseUint(s, 10, 64)
if err != nil {
return err
}
*v = n
return nil
case *float32:
n, err := strconv.ParseFloat(s, 32)
if err != nil {
return err
}
*v = float32(n)
return err
case *float64:
var err error
*v, err = strconv.ParseFloat(s, 64)
return err
case *bool:
*v = len(s) == 1 && s[0] == '1'
return nil
case encoding.BinaryUnmarshaler:
return v.UnmarshalBinary([]byte(s))
default:
return fmt.Errorf(
"redis: can't unmarshal %T (consider implementing BinaryUnmarshaler)", v)
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/github-image/go-redis-redis.git
git@gitee.com:github-image/go-redis-redis.git
github-image
go-redis-redis
go-redis-redis
v5.1.3

Search