Documentation ¶
Overview ¶
Package govert provides you some helpers to convert basic data types specially interfaces to other basic types.
Index ¶
- func Bool(in interface{}) (out bool)
- func Complex128(in interface{}) (out complex128)
- func Complex64(in interface{}) (out complex64)
- func Float32(in interface{}) (out float32)
- func Float64(in interface{}) (out float64)
- func Int(in interface{}) (out int)
- func Int16(in interface{}) (out int16)
- func Int32(in interface{}) (out int32)
- func Int64(in interface{}) (out int64)
- func Int8(in interface{}) (out int8)
- func String(in interface{}, params ...interface{}) (out string)
- func This(in, out interface{}, params ...interface{}) (err error)
- func Uint(in interface{}) (out uint)
- func Uint16(in interface{}) (out uint16)
- func Uint32(in interface{}) (out uint32)
- func Uint64(in interface{}) (out uint64)
- func Uint8(in interface{}) (out uint8)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bool ¶
func Bool(in interface{}) (out bool)
Bool converts basic types to bool.
// will return false if input interface is numeric and is equal to 0. fmt.Println(govert.Bool(224.58719)) // true fmt.Println(govert.Bool(0)) // false // will return true if input interface is string and is equal to "true" or "1", compared case insensitive. fmt.Println(govert.Bool("anything")) // false fmt.Println(govert.Bool("false")) // false fmt.Println(govert.Bool("True")) // true fmt.Println(govert.Bool("true")) // true fmt.Println(govert.Bool("1")) // true
func Complex128 ¶
func Complex128(in interface{}) (out complex128)
Complex128 converts basic types to complex128
func Complex64 ¶
func Complex64(in interface{}) (out complex64)
Complex64 converts basic types to complex64
func String ¶
func String(in interface{}, params ...interface{}) (out string)
String converts any type to string second parameter is used when you try to convert float to string as number of digits after decimal point. note that golang will round the result.
fmt.Println(govert.String(224.58719,2)) // 224.59 fmt.Println(govert.String(224.58719,3)) // 224.587
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.