Documentation
¶
Index ¶
- Variables
- func CheckFunction(fn interface{}, params ...interface{}) (*reflect.Value, *[]reflect.Value, error)
- func GetDereferencedType(instance interface{}) reflect.Type
- func GetDereferencedValue(instance interface{}) reflect.Value
- func GetType(instance interface{}) reflect.Type
- func GetTypeName(typeReflection reflect.Type) string
- func GetTypeOf(bodyType interface{}) reflect.Type
- func GetValue(instance interface{}) reflect.Value
- func NewInstance(bodyType interface{}) interface{}
- func NewInstanceFromType(t reflect.Type) interface{}
- func SafeCallFunction(fn interface{}, params ...interface{}) ([]interface{}, error)
- func UnsafeCallFunction(fnValue *reflect.Value, paramsValues ...reflect.Value) ([]interface{}, error)
- type Reflection
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotAFunction = errors.New("not a function") ErrFunctionParameterCountMismatch = "function parameter count mismatch, expected %d, got %d" ErrFunctionParameterTypeMismatch = "function parameter type mismatch on index %d, expected %s, got %s" ErrNilFunctionValue = errors.New("nil function value") )
Functions ¶
func CheckFunction ¶ added in v0.2.2
func CheckFunction(fn interface{}, params ...interface{}) ( *reflect.Value, *[]reflect.Value, error, )
CheckFunction checks if a function is valid
func GetDereferencedType ¶
GetDereferencedType returns the dereferenced type reflection
func GetDereferencedValue ¶
GetDereferencedValue returns the dereferenced value reflection
func GetTypeName ¶
GetTypeName returns the type name
func NewInstance ¶ added in v0.2.1
func NewInstance(bodyType interface{}) interface{}
NewInstance creates a new instance of the given type
func NewInstanceFromType ¶ added in v0.2.1
NewInstanceFromType creates a new instance of the given type
func SafeCallFunction ¶ added in v0.2.3
func SafeCallFunction(fn interface{}, params ...interface{}) ( []interface{}, error, )
SafeCallFunction calls a function with some typed parameters after checking if the function is valid
Types ¶
type Reflection ¶
type Reflection struct {
// contains filtered or unexported fields
}
Reflection struct to hold reflection data
func NewDereferencedReflection ¶
func NewDereferencedReflection(instance interface{}) *Reflection
NewDereferencedReflection creates a new reflection from a dereferenced instance
func NewReflection ¶
func NewReflection(instance interface{}) *Reflection
NewReflection creates a new reflection from an instance
func (*Reflection) GetInstance ¶
func (r *Reflection) GetInstance() interface{}
GetInstance returns the instance
func (*Reflection) GetReflectedType ¶
func (r *Reflection) GetReflectedType() reflect.Type
GetReflectedType returns the reflected type
func (*Reflection) GetReflectedTypeName ¶
func (r *Reflection) GetReflectedTypeName() string
GetReflectedTypeName returns the reflected type name
func (*Reflection) GetReflectedValue ¶
func (r *Reflection) GetReflectedValue() reflect.Value
GetReflectedValue returns the reflected value