Documentation ¶
Overview ¶
Package require provides convenient type conversions.
Index ¶
- Variables
- func Bool(value interface{}) bool
- func Byte(num interface{}, defaultValue ...byte) byte
- func Float32(num interface{}, defaultValue ...float32) float32
- func Float64(num interface{}, defaultValue ...float64) float64
- func Int(num interface{}, defaultValue ...int) int
- func Int32(num interface{}, defaultValue ...int32) int32
- func Int64(num interface{}, defaultValue ...int64) int64
- func IsNumber(i interface{}) bool
- func Number(value interface{}, kind reflect.Kind) interface{}
- func SiMap(i interface{}) map[string]interface{}
- func String(i interface{}, defaultString ...string) string
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func Bool ¶ added in v0.1.7
func Bool(value interface{}) bool
Bool converts the given value to bool. If the value's type is bool returns this value. Otherwise, returns true if the value is not nil.
func Byte ¶
Byte converts the given number or string value to byte. If conversion is not possible returns the given default value or 0 if no default value is specified.
func Float32 ¶
Float32 converts the given number or string value to float32. If conversion is not possible returns the given default value or 0 if no default value is specified.
func Float64 ¶
Float64 converts the given number or string value to float64. If conversion is not possible returns the given default value or 0 if no default value is specified.
func Int ¶
Int converts the given number or string value to int. If conversion is not possible returns the given default value or 0 if no default value is specified.
func Int32 ¶
Int32 converts the given number or string value to int32. If conversion is not possible returns the given default value or 0 if no default value is specified.
func Int64 ¶
Int64 converts the given number or string value to int64. If conversion is not possible returns the given default value or 0 if no default value is specified.
func IsNumber ¶
func IsNumber(i interface{}) bool
IsNumber checks if the given value's type is one of the supported number types: byte, int, int32, int64, float32, float64.
func Number ¶
Number converts the given number value to the given number type. If conversion is not possible returns 0.
Types ¶
This section is empty.