tags

package
v0.0.0-...-710c528 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNil = errors.New("nil returned")

ErrNil indicates that a reply value is nil.

Functions

func Bool

func Bool(reply interface{}) (bool, error)

Bool is a helper that converts a command reply to a boolean. If err is not equal to nil, then Bool returns false, err. Otherwise Bool converts the reply to boolean as follows:

Reply type      ExecResult
integer         value != 0, nil
bulk string     strconv.ParseBool(reply)
nil             false, ErrNil
other           false, error

func BoolDefault

func BoolDefault(reply interface{}, def ...bool) bool

BoolDefault is a helper that converts a command reply to a boolean. If err is not equal to nil, then Bool returns default value

func ByteSlices

func ByteSlices(reply interface{}) ([][]byte, error)

ByteSlices is a helper that converts an array command reply to a [][]byte. If err is not equal to nil, then ByteSlices returns nil, err. Nil array items are stay nil. ByteSlices returns an error if an array item is not a bulk string or nil.

func Bytes

func Bytes(reply interface{}) ([]byte, error)

Bytes is a helper that converts a command reply to a slice of bytes. If err is not equal to nil, then Bytes returns nil, err. Otherwise Bytes converts the reply to a slice of bytes as follows:

Reply type      ExecResult
bulk string     reply, nil
simple string   []byte(reply), nil
nil             nil, ErrNil
other           nil, error

func BytesDefault

func BytesDefault(reply interface{}, def ...[]byte) []byte

BytesDefault is a helper that converts a command reply to a slice of bytes. If err is not equal to nil, then Bytes returns default value

func Copy

func Copy(dst, src interface{})

Copy 转换对象值,对象字段名称相同并且类型相同时自动赋值相应字段 @param dst interface{} 目标对象 @param src interface{} 原始对象

func DbTag

func DbTag(tp reflect.Type) (map[string]string, string)

dbTag 解析对象数据库结构 @param tp reflect.Type 对象类型 @return map[string]string 对象数据库结构字段对照表 @return string 对象数据库主键字段名

func Float64

func Float64(reply interface{}) (float64, error)

Float64 is a helper that converts a command reply to 64 bit float. If err is not equal to nil, then Float64 returns 0, err. Otherwise, Float64 converts the reply to an int as follows:

Reply type    ExecResult
bulk string   parsed reply, nil
nil           0, ErrNil
other         0, error

func Float64Default

func Float64Default(reply interface{}, def ...float64) float64

Float64Default is a helper that converts a command reply to 64 bit float. If err is not equal to nil, then return default value

func GetPtrInterface

func GetPtrInterface(v reflect.Value) interface{}

getPtrInterface 获取指针的原始对象

func Int

func Int(reply interface{}) (int, error)

Int is a helper that converts a command reply to an integer. If err is not equal to nil, then Int returns 0, err. Otherwise, Int converts the reply to an int as follows:

Reply type    ExecResult
integer       int(reply), nil
bulk string   parsed reply, nil
nil           0, ErrNil
other         0, error

func Int64

func Int64(reply interface{}) (int64, error)

Int64 is a helper that converts a command reply to 64 bit integer. If err is not equal to nil, then Int returns 0, err. Otherwise, Int64 converts the reply to an int64 as follows:

Reply type    ExecResult
integer       reply, nil
bulk string   parsed reply, nil
nil           0, ErrNil
other         0, error

func Int64Default

func Int64Default(reply interface{}, def ...int64) int64

Int64Default is a helper that converts 64 bit integer. If err is not equal to nil, then return default value

func Int64Map

func Int64Map(result interface{}) (map[string]int64, error)

Int64Map is a helper that converts an array of strings (alternating key, value) into a map[string]int64. The HGETALL commands return replies in this format. Requires an even number of values in result.

func IntDefault

func IntDefault(reply interface{}, def ...int) int

IntDefault is a helper that converts interface to an integer. If err is not equal to nil, then return default value

func IntMap

func IntMap(result interface{}) (map[string]int, error)

IntMap is a helper that converts an array of strings (alternating key, value) into a map[string]int. The HGETALL commands return replies in this format. Requires an even number of values in result.

func IsEmpty

func IsEmpty(v reflect.Value) bool

判断值是否为空

func MultiBulk deprecated

func MultiBulk(reply interface{}) ([]interface{}, error)

MultiBulk is a helper that converts an array command reply to a []interface{}.

Deprecated: Use Values instead.

func SetMapValue

func SetMapValue(obj interface{}, m map[string]interface{})

SetMapValue 设置对象值

func String

func String(reply interface{}) (string, error)

String is a helper that converts a command reply to a string. If err is not equal to nil, then String returns "", err. Otherwise String converts the reply to a string as follows:

Reply type      ExecResult
bulk string     string(reply), nil
simple string   reply, nil
nil             "",  ErrNil
other           "",  error

func StringDefault

func StringDefault(reply interface{}, def ...string) string

StringDefault is a helper that converts a command reply to a string. If err is not equal to nil, then String returns default value

func StringMap

func StringMap(result interface{}) (map[string]string, error)

StringMap is a helper that converts an array of strings (alternating key, value) into a map[string]string. The HGETALL and CONFIG GET commands return replies in this format. Requires an even number of values in result.

func Strings

func Strings(reply interface{}) ([]string, error)

Strings is a helper that converts an array command reply to a []string. If err is not equal to nil, then Strings returns nil, err. Nil array items are converted to "" in the output slice. Strings returns an error if an array item is not a bulk string or nil.

func Uint64

func Uint64(reply interface{}) (uint64, error)

Uint64 is a helper that converts a command reply to 64 bit integer. If err is not equal to nil, then Int returns 0, err. Otherwise, Int64 converts the reply to an int64 as follows:

Reply type    ExecResult
integer       reply, nil
bulk string   parsed reply, nil
nil           0, ErrNil
other         0, error

func Uint64Default

func Uint64Default(reply interface{}, def ...uint64) uint64

Uint64Default is a helper that converts to 64 bit integer. If err is not equal to nil, then return default value

func Values

func Values(reply interface{}) ([]interface{}, error)

Values is a helper that converts an array command reply to a []interface{}. If err is not equal to nil, then Values returns nil, err. Otherwise, Values converts the reply as follows:

Reply type      ExecResult
array           reply, nil
nil             nil, ErrNil
other           nil, error

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL