Documentation ¶
Index ¶
- Variables
- func Convert(in interface{}, out interface{}) error
- func Equal(obj1, obj2 interface{}) bool
- func IsFloat(typ reflect.Type) bool
- func IsInt(typ reflect.Type) bool
- func IsNumeric(typ reflect.Type) bool
- func IsTrue(value interface{}) (truth, ok bool)
- func IsTrueVal(val reflect.Value) (truth, ok bool)
- func IsUint(typ reflect.Type) bool
- func SettableValue(val interface{}) (reflect.Value, error)
- func SortValues(v []reflect.Value) error
- func ToFloat(val interface{}) (float64, error)
- func ToInt(val interface{}) (int, error)
- func ToInt64(val interface{}) (int64, error)
- func ToString(val interface{}) string
- func ToUint(val interface{}) (uint, error)
- func ToUint64(val interface{}) (uint64, error)
- type KindGroup
Constants ¶
This section is empty.
Variables ¶
var ( ErrCantSet = errors.New("can't set value (you might need to pass a pointer)") ErrInvalidValue = errors.New("invalid value") )
Functions ¶
func Convert ¶
func Convert(in interface{}, out interface{}) error
Convert converts the in parameter to the out parameter, which must be a non-nil pointer, usually to a different type than in. Supported parameters type are u?int(8|16|32|64)?, float(32|64) and string.
func IsNumeric ¶
IsNumeric returns true iff the type is one of the int, uint, float or complex types.
func IsTrue ¶
func IsTrue(value interface{}) (truth, ok bool)
IsTrue returns whether the value is 'true', in the sense of not the zero of its type, and whether the value has a meaningful truth value. This function is a copy of the one found in text/template
func IsTrueVal ¶
IsTrueVal works like IsTrue, but accepts a reflect.Value rather than an interface{}.
func SettableValue ¶
func SortValues ¶
SortValues sorts the given slice of reflect.Value, if possible. If the slice can't be sorted, an error is returned.
func ToFloat ¶
ToFloat tries to convert its argument to a 64-bit float. It will convert bool, int, uint and its variants, floats and even strings if it can parse them.
func ToInt ¶
ToInt tries to convert its argument to an integer. It will convert bool, int, uint and its variants, floats and even strings if it can parse them.
func ToInt64 ¶
ToInt64 tries to convert its argument to an int64. It will convert bool, int, uint and its variants, floats and even strings if it can parse them.
func ToString ¶
func ToString(val interface{}) string
ToString transforms the given value into a string. If the value is a nil pointer or a nil interface, it returns the empty string.
Types ¶
type KindGroup ¶
type KindGroup uint
KindGroup groups different reflect Kinds which support the same set of operations
const ( // Invalid includes reflect.Invalid Invalid KindGroup = iota // Bool includes reflect.Bool Bool // Int includes reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32 and reflect.Int64 Int // Uint includes reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32 and reflect.Uint64 Uint // Uintptr includes reflect.Uintptr Uintptr // Float includes reflect.Float32 and reflect.Float64 Float // Complex includes reflect.Complex64 and reflect.Complex128 Complex // Array includes reflect.Array Array // Chan includes reflect.Chan Chan // Func includes reflect.Func Func // Interface includes reflect.Interface Interface // Map includes reflect.Map Map // Ptr includes reflect.Ptr Ptr // Slice includes reflect.Slice Slice // String includes reflect.String String // Struct includes reflect.Struct Struct // UnsafePointer includes reflect.UnsafePointer UnsafePointer )