Documentation ¶
Index ¶
- Constants
- Variables
- func AppendValue(value reflect.Value, val string) error
- func AppendValues(value reflect.Value, vals ...string) error
- func ConvertSliceElemType(vals interface{}, val interface{}) interface{}
- func DeepCopy(v interface{}) interface{}
- func DeepCopyRv(rv reflect.Value) reflect.Value
- func GetInstanceTypeName(instance interface{}) string
- func InCollection(obj interface{}, array interface{}) bool
- func IsFieldExportable(fieldName string) bool
- func IsNil(val interface{}) bool
- func IsSerializable(valType reflect.Type) bool
- func ParseValue(val string, tp reflect.Type) (reflect.Value, error)
- func RegisterSerializable(valType reflect.Type, alloc FuncSerializableAllocator)
- func RegisterSerializableTransformer(valType reflect.Type, trans FuncSerializableTransformer)
- func SetValue(value reflect.Value, valStr string) error
- func SliceBaseType(tp reflect.Type) reflect.Type
- type DeepCopyFlags
- type FuncSerializableAllocator
- type FuncSerializableTransformer
- type IDeepCopy
- type ISerializable
Constants ¶
View Source
const (
EMPTYSTR = ""
)
Variables ¶
View Source
var ( BoolType = reflect.TypeOf(boolValue) IntType = reflect.TypeOf(intValue) Int8Type = reflect.TypeOf(int8Value) Int16Type = reflect.TypeOf(int16Value) Int32Type = reflect.TypeOf(int32Value) Int64Type = reflect.TypeOf(int64Value) UintType = reflect.TypeOf(uintValue) Uint8Type = reflect.TypeOf(uint8Value) Uint16Type = reflect.TypeOf(uint16Value) Uint32Type = reflect.TypeOf(uint32Value) Uint64Type = reflect.TypeOf(uint64Value) Float32Type = reflect.TypeOf(float32Value) Float64Type = reflect.TypeOf(float64Value) StringType = reflect.TypeOf(stringValue) BoolSliceType = reflect.TypeOf(boolSliceValue) IntSliceType = reflect.TypeOf(intSliceValue) Int8SliceType = reflect.TypeOf(int8SliceValue) Int16SliceType = reflect.TypeOf(int16SliceValue) Int32SliceType = reflect.TypeOf(int32SliceValue) Int64SliceType = reflect.TypeOf(int64SliceValue) UintSliceType = reflect.TypeOf(uintSliceValue) Uint8SliceType = reflect.TypeOf(uint8SliceValue) Uint16SliceType = reflect.TypeOf(uint16SliceValue) Uint32SliceType = reflect.TypeOf(uint32SliceValue) Uint64SliceType = reflect.TypeOf(uint64SliceValue) Float32SliceType = reflect.TypeOf(float32SliceValue) Float64SliceType = reflect.TypeOf(float64SliceValue) StringSliceType = reflect.TypeOf(stringSliceValue) TimeType = reflect.TypeOf(timeValue) )
View Source
var ( ISerializableType = reflect.TypeOf((*ISerializable)(nil)).Elem() ErrTypeNotSerializable = errors.New("Type not serializable") )
Functions ¶
func ConvertSliceElemType ¶
func ConvertSliceElemType(vals interface{}, val interface{}) interface{}
Convert vals to slice of pointer val's element type
This is for the following use cases, not for general type conversion
- Convert []Interface to []ConcreteType
- Convert []ConcreateType to []Interface
func DeepCopy ¶
func DeepCopy(v interface{}) interface{}
DeepCopy copies the passed argument recursively
There are a few constraint
- It cannot handle un-exported fields
- It cannot handle circular references. Doing so will cause runtime stack overflow panic
func GetInstanceTypeName ¶
func GetInstanceTypeName(instance interface{}) string
func InCollection ¶
func InCollection(obj interface{}, array interface{}) bool
func IsFieldExportable ¶
func IsSerializable ¶
func RegisterSerializable ¶
func RegisterSerializable(valType reflect.Type, alloc FuncSerializableAllocator)
RegisterSerializable registers an allocator func for the specified serializable type.
This is intended to be used when you have multiple implmenetations of an interface and you want to use only one of them to cover them all. TokenCredential and SSimpleToken is such a case.
func RegisterSerializableTransformer ¶
func RegisterSerializableTransformer(valType reflect.Type, trans FuncSerializableTransformer)
Types ¶
type DeepCopyFlags ¶
type DeepCopyFlags uintptr
type FuncSerializableAllocator ¶
type FuncSerializableAllocator func() ISerializable
type FuncSerializableTransformer ¶
type FuncSerializableTransformer func(ISerializable) ISerializable
type ISerializable ¶
type ISerializable interface { String() string // FromString(str string) error // Equals(obj ISerializable) bool IsZero() bool }
func NewSerializable ¶
func NewSerializable(objType reflect.Type) (ISerializable, error)
func Transform ¶
func Transform(objType reflect.Type, retVal ISerializable) ISerializable
Click to show internal directories.
Click to hide internal directories.