Documentation ¶
Index ¶
- func Contains(sliceInterface interface{}, value interface{}) bool
- func FormatByteSize(v uint64) string
- func FormatNumber(v interface{}) string
- func IndexOf(sliceInterface interface{}, value interface{}) int
- func IsEmpty(object interface{}) bool
- func IsNil(object interface{}) bool
- func MapToStruct(mapData map[string]interface{}, _value interface{}) (newStruct interface{}, err error)
- func MapToStructWithTag(mapData map[string]interface{}, _value interface{}, tag string) (newStruct interface{}, err error)
- func ParseByteSize(v string) uint64
- func ParseNumber(v string) int64
- type AnyValue
- func (s *AnyValue) Bool() bool
- func (s *AnyValue) BoolSlice() []bool
- func (s *AnyValue) Bytes() []byte
- func (s *AnyValue) Duration() time.Duration
- func (s *AnyValue) DurationSlice() []time.Duration
- func (s *AnyValue) Float32() float32
- func (s *AnyValue) Float32Slice() []float32
- func (s *AnyValue) Float64() float64
- func (s *AnyValue) Float64Slice() []float64
- func (s *AnyValue) Int() int
- func (s *AnyValue) Int32() int32
- func (s *AnyValue) Int32Slice() []int32
- func (s *AnyValue) Int64() int64
- func (s *AnyValue) Int64Slice() []int64
- func (s *AnyValue) Int8() int8
- func (s *AnyValue) Int8Slice() []int8
- func (s *AnyValue) IntSlice() []int
- func (s *AnyValue) Map() map[string]interface{}
- func (s *AnyValue) MapBool() map[string]bool
- func (s *AnyValue) MapFloat32() map[string]float32
- func (s *AnyValue) MapFloat64() map[string]float64
- func (s *AnyValue) MapInt() map[string]int
- func (s *AnyValue) MapInt32() map[string]int32
- func (s *AnyValue) MapInt64() map[string]int64
- func (s *AnyValue) MapInt8() map[string]int8
- func (s *AnyValue) MapString() map[string]string
- func (s *AnyValue) MapUint() map[string]uint
- func (s *AnyValue) MapUint32() map[string]uint32
- func (s *AnyValue) MapUint64() map[string]uint64
- func (s *AnyValue) MapUint8() map[string]uint8
- func (s *AnyValue) Slice() []interface{}
- func (s *AnyValue) String() string
- func (s *AnyValue) StringSlice() []string
- func (s *AnyValue) Time() time.Time
- func (s *AnyValue) Uint() uint
- func (s *AnyValue) Uint32() uint32
- func (s *AnyValue) Uint32Slice() []uint32
- func (s *AnyValue) Uint64() uint64
- func (s *AnyValue) Uint64Slice() []uint64
- func (s *AnyValue) Uint8() uint8
- func (s *AnyValue) Uint8Slice() []uint8
- func (s *AnyValue) UintSlice() []uint
- func (s *AnyValue) Val() interface{}
- type Value
- func (s *Value) Bool() bool
- func (s *Value) Bytes() []byte
- func (s *Value) Duration() time.Duration
- func (s *Value) Float32() float32
- func (s *Value) Float64() float64
- func (s *Value) Int() int
- func (s *Value) Int32() int32
- func (s *Value) Int64() int64
- func (s *Value) Int8() int8
- func (s *Value) Map() map[string]interface{}
- func (s *Value) MapBool() map[string]bool
- func (s *Value) MapFloat32() map[string]float32
- func (s *Value) MapFloat64() map[string]float64
- func (s *Value) MapInt() map[string]int
- func (s *Value) MapInt32() map[string]int32
- func (s *Value) MapInt64() map[string]int64
- func (s *Value) MapInt8() map[string]int8
- func (s *Value) MapSlice() map[string][]interface{}
- func (s *Value) MapString() map[string]string
- func (s *Value) MapStringSlice() map[string][]string
- func (s *Value) MapUint() map[string]uint
- func (s *Value) MapUint32() map[string]uint32
- func (s *Value) MapUint64() map[string]uint64
- func (s *Value) MapUint8() map[string]uint8
- func (s *Value) Slice() []interface{}
- func (s *Value) String() string
- func (s *Value) StringSlice() []string
- func (s *Value) Time() time.Time
- func (s *Value) Uint() uint
- func (s *Value) Uint32() uint32
- func (s *Value) Uint64() uint64
- func (s *Value) Uint8() uint8
- func (s *Value) Val() interface{}
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
func Contains(sliceInterface interface{}, value interface{}) bool
Contains check the input slice if contains the value
func FormatByteSize ¶
FormatByteSize convert byte size v to human-readable format, for example 1024 -> 1K
func FormatNumber ¶
func FormatNumber(v interface{}) string
FormatNumber return split by comma format of number v. v must be intX, uintX or intX string, uintX string, example: 10000 -> 10,000
func IndexOf ¶
func IndexOf(sliceInterface interface{}, value interface{}) int
IndexOf returns the index of value in slice, if not found -1 returned
func IsEmpty ¶
func IsEmpty(object interface{}) bool
IsEmpty if object is IsNil with true, or is empty string, return true, others false.
func IsNil ¶
func IsNil(object interface{}) bool
IsNil if object is nil or a nil pointer variable or nil builtin pointer variable(chan,func,interface,map,ptr,slice) return true, others false.
func MapToStruct ¶
func MapToStruct(mapData map[string]interface{}, _value interface{}) (newStruct interface{}, err error)
MapToStruct same with MapToStructWithTag, but `json` is used as tag name by default
func MapToStructWithTag ¶
func MapToStructWithTag(mapData map[string]interface{}, _value interface{}, tag string) (newStruct interface{}, err error)
MapToStructWithTag convert map to struct, _value is a pointer to strut, if key 'tag' not exists in the map, the filed name will used as map key. Returned newStruct is a struct, for example: newStruct.(User) to assert it type. Details refer to TestMapToStruct. Ignore filed, set tag tagName:"-", for example: User{ Age int `tagName:"-"` }
func ParseByteSize ¶
ParseByteSize convert human-readable byte size format v to byte size, v can be: 1, 1B, 1KB, 1.1KB, 1MB, 1GB, 1TB, 1PB, 1EB
func ParseNumber ¶
ParseNumber convert human-readable number format v to int64, example: 100,123 -> 100123
Types ¶
type AnyValue ¶
type AnyValue struct {
// contains filtered or unexported fields
}
func Keys ¶
func Keys(_map interface{}) *AnyValue
Keys input _map is a map, returns its keys as slice, AnyValue.xxxSlice to get the typed slice.
func NewAny ¶
func NewAny(val interface{}) *AnyValue
NewAny wrap the val with type *AnyValue, *AnyValue.XXX() convert val to type XXX.
func (*AnyValue) DurationSlice ¶
func (*AnyValue) Float32Slice ¶
func (*AnyValue) Float64Slice ¶
func (*AnyValue) Int32Slice ¶
func (*AnyValue) Int64Slice ¶
func (*AnyValue) MapFloat32 ¶
func (*AnyValue) MapFloat64 ¶
func (*AnyValue) StringSlice ¶
func (*AnyValue) Uint32Slice ¶
func (*AnyValue) Uint64Slice ¶
func (*AnyValue) Uint8Slice ¶
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
func GetValueAt ¶
GetValueAt sliceOrArray is slice or array, idx is the element to get, if idx invalid or sliceOrArray is not slice or array, the default value will be used
func New ¶
func New(val interface{}) *Value
New wrap the val with type *Value, type val and *Value.XXX() must be same.