Documentation ¶
Overview ¶
Package TypeConverter implements type conversion. Used to safely obtain data of the specified type.
Index ¶
- func BoolToComplex(input bool, bitSize int) interface{}
- func BoolToFloat(input bool, bitSize int) interface{}
- func BoolToInt(input bool, bitSize int) interface{}
- func BoolToMap(input bool) map[string]interface{}
- func BoolToSlice(input bool) []interface{}
- func BoolToString(input bool) string
- func BoolToUint(input bool, bitSize int) interface{}
- func ComplexToString(c complex128) string
- func FloatToString(i float64) string
- func IntToString(i int64) string
- func MapEqual(d1, d2 map[string]interface{}) bool
- func MapToBytes(input map[string]interface{}) []byte
- func MapToSlice(input map[string]interface{}) []interface{}
- func MapToStringMapInterface(input interface{}) map[string]interface{}
- func SliceEqual(d1, d2 []interface{}) bool
- func SliceIsBytes(input []interface{}) bool
- func SliceToBytes(input []interface{}) []byte
- func SliceToInterfaceSlice(input interface{}) []interface{}
- func SliceToMap(input []interface{}) map[string]interface{}
- func SliceToString(input []interface{}) string
- func StringToBool(input string) bool
- func StringToBytes(input string) []byte
- func StringToComplex(input string, bitSize int) interface{}
- func StringToFloat(input string, bitSize int) interface{}
- func StringToInt(input string, bitSize int) interface{}
- func StringToMap(input string) map[string]interface{}
- func StringToSlice(input string) []interface{}
- func StringToUint(input string, bitSize int) interface{}
- func UintToString(i uint64) string
- type TypeConverter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BoolToComplex ¶
BoolToComplex Convert bool to complex.
func BoolToFloat ¶
BoolToFloat Convert bool to float.
func BoolToUint ¶
BoolToUint Convert bool to uint.
func ComplexToString ¶
func ComplexToString(c complex128) string
ComplexToString Convert complex128 to string.
func MapToBytes ¶
MapToString Convert map[string]interface{} to []byte.
func MapToSlice ¶
func MapToSlice(input map[string]interface{}) []interface{}
MapToSlice Convert map[string]interface{} to []interface{}.
func MapToStringMapInterface ¶
func MapToStringMapInterface(input interface{}) map[string]interface{}
MapToStringMapInterface Convert map[string]interface{} to map[string]interface{}.
func SliceEqual ¶
func SliceEqual(d1, d2 []interface{}) bool
SliceEqual Compares two slices for equality.
func SliceIsBytes ¶
func SliceIsBytes(input []interface{}) bool
SliceIsBytes check is []uint8 or []byte.
func SliceToBytes ¶
func SliceToBytes(input []interface{}) []byte
SliceToString Convert slice to string.
func SliceToInterfaceSlice ¶
func SliceToInterfaceSlice(input interface{}) []interface{}
SliceToInterfaceSlice Convert slice to []interface{}.
func SliceToMap ¶
func SliceToMap(input []interface{}) map[string]interface{}
SliceToMap Convert slice to map[string]interface{}
func SliceToString ¶
func SliceToString(input []interface{}) string
SliceToString Convert slice to string.
func StringToComplex ¶
StringToComplex Convert string to complex. bitSize: 64/128.
func StringToFloat ¶
StringToFloat Convert string to float.
func StringToInt ¶
StringToInt Convert string to int.
func StringToMap ¶
StringToMap Convert string to map.
func StringToSlice ¶
func StringToSlice(input string) []interface{}
StringToSlice Convert string to slice.
func StringToUint ¶
StringToUint Convert string to uint.
Types ¶
type TypeConverter ¶
type TypeConverter struct { // String string String string // Byte byte Byte byte // Bytes []byte Bytes []byte // Bool bool Bool bool // Int int Int int // Int8 int8 Int8 int8 // Int16 int16 Int16 int16 // Int32 int32 Int32 int32 // Int64 int64 Int64 int64 // Uint unsigened int Uint uint // Uint8 unsigened int8 Uint8 uint8 // Uint16 unsigened int16 Uint16 uint16 // Uint32 unsigened int32 Uint32 uint32 // Uint64 unsigened int64 Uint64 uint64 // Float32 float32 Float32 float32 // Float64 float64 Float64 float64 // Complex64 complex64 Complex64 complex64 // Complex128 complex128 Complex128 complex128 // Slice []interface{} Slice []interface{} // Map map[string]interface{} Map map[string]interface{} }
TypeConverter .
func BoolToStruct ¶
func BoolToStruct(input bool) *TypeConverter
BoolToStruct Build *TypeConverter by input string.
func MapToStruct ¶
func MapToStruct(input map[string]interface{}) *TypeConverter
MapToStruct Convert map[string]interface{} to struct.
func SliceToStruct ¶
func SliceToStruct(input []interface{}) *TypeConverter
SliceToStruct Convert slice to struct.
func StringToStruct ¶
func StringToStruct(input string) *TypeConverter
StringToStruct Build *TypeConverter by input string.
func (*TypeConverter) Compare ¶
func (tc *TypeConverter) Compare(operator string, compareData interface{}) bool
Compare Pass in the new object and operator to compare against the current object. The optional operators are: EQ - = NEQ - != GT - > EGT - >= LT - < ELT - <=
func (*TypeConverter) Equal ¶
func (tc *TypeConverter) Equal(compareData interface{}) bool
Equal Pass in a new object and compare it with the current object to check if the values are equal.