Documentation
¶
Overview ¶
Package reflect contains a collection of helpful generic functions that support reflection. It is currently not part of the public interface and must be consider as highly instable.
Index ¶
- Constants
- Variables
- func AnyFuncOf(args int, variadic bool) reflect.Type
- func ArgOf(v reflect.Value) any
- func ArgsOf(values ...reflect.Value) []any
- func BaseFuncOf(mtype reflect.Type, in, out int) reflect.Type
- func FieldArgOf(v reflect.Value, i int) any
- func FindArgOf[P any](param P, deflt any, names ...string) any
- func MakeFuncOf(mtype reflect.Type, call func([]reflect.Value) []reflect.Value) any
- func NewErrInvalidType(index int, expect, actual reflect.Type) error
- func ValuesIn(ftype reflect.Type, args ...any) []reflect.Value
- func ValuesOut(ftype reflect.Type, lenient bool, args ...any) []reflect.Value
- type Type
- type Value
Constants ¶
const ( // Func alias for `reflect.Func`. Func = reflect.Func )
Aliases for constant values.
Variables ¶
var ( // TypeOf alias for `reflect.TypeOf`. TypeOf = reflect.TypeOf // ValueOf alias for `reflect.ValueOf`. ValueOf = reflect.ValueOf )
Aliases for function values.
Functions ¶
func BaseFuncOf ¶
BaseFuncOf allows to extract a base function from an interface function containing no receiver and suppressing the return values - if necessary. The given `in` and `out` values allow to restrict the included input and output arguments. Use `1` to remove the first argument, or `NumIn/NumOut` to remove all arguments.
func FieldArgOf ¶
FieldArgOf returns the argument of the `i`th field of the given value.
func FindArgOf ¶
FindArgOf find the first argument with one of the given field names matching the type matching the default argument type.
func MakeFuncOf ¶
MakeFuncOf returns a newly created function with given reflective function.
func NewErrInvalidType ¶
NewErrInvalidType creates a new error reporting an invalid type during value slice creation.
func ValuesIn ¶
ValuesIn returns the reflection values matching the input arguments of the given function.