Documentation
¶
Overview ¶
Reflect utility package.
Index ¶
- func Clone(rv reflect.Value) (any, bool)
- func CloneArray(rv reflect.Value) (any, bool)
- func CloneMap(rv reflect.Value) (any, bool)
- func CloneSlice(rv reflect.Value) (any, bool)
- func CollectFields(ptr any) []reflect.StructField
- func CollectTypeFields(eleType reflect.Type) []reflect.StructField
- func FindEmbedStruct[T any](v any) (T, bool)
- func FuncName(f any) string
- func IsAnyNil(v any) bool
- func IsBasicKind(k reflect.Kind) bool
- func IsFieldExposed(fieldName string) bool
- func NewVar[T any]() T
- func ReflectBasicValue(rv reflect.Value) (any, bool)
- func ReflectFuncName(fun any) string
- func ReflectGenMap(t any) map[string]any
- func TypeName(t reflect.Type) string
- func TypePkgPath(f reflect.Type) string
- func WalkTagShallow(ptr any, callbacks ...WalkTagCallback) error
- type ForEachField
- type Introspector
- func (it *Introspector) Field(fieldName string) (field reflect.StructField, isFieldFound bool)
- func (it *Introspector) FieldAt(idx int) (field reflect.StructField)
- func (it *Introspector) FieldIdx(fieldName string) (index int, isFieldFound bool)
- func (it *Introspector) IterFields(forEach ForEachField)
- func (it *Introspector) Tag(fieldName string, tagName string) (tag string, isFieldFound bool)
- func (it *Introspector) TagRetriever(fieldName string) (t TagRetriever, isFieldFound bool)
- type TagRetriever
- type WalkTagCallback
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CollectTypeFields ¶
func CollectTypeFields(eleType reflect.Type) []reflect.StructField
Get Fields of A Type
func FindEmbedStruct ¶
func IsBasicKind ¶
func ReflectFuncName ¶
func ReflectGenMap ¶
Construct Struct/Interface/Pointer values to map[string]any.
This method doesn't convert recursively.
func TypePkgPath ¶ added in v0.4.10
func WalkTagShallow ¶
func WalkTagShallow(ptr any, callbacks ...WalkTagCallback) error
Walk fields of *struct, won't go deeper even if the field is a struct.
Types ¶
type ForEachField ¶
type ForEachField func(index int, field reflect.StructField) (breakIteration bool)
type Introspector ¶
type Introspector struct {
Type reflect.Type
Fields []reflect.StructField
// contains filtered or unexported fields
}
func (*Introspector) Field ¶
func (it *Introspector) Field(fieldName string) (field reflect.StructField, isFieldFound bool)
Get field by name
func (*Introspector) FieldAt ¶
func (it *Introspector) FieldAt(idx int) (field reflect.StructField)
Get field at index
func (*Introspector) FieldIdx ¶
func (it *Introspector) FieldIdx(fieldName string) (index int, isFieldFound bool)
Get field index
func (*Introspector) IterFields ¶
func (it *Introspector) IterFields(forEach ForEachField)
Iterate fields
func (*Introspector) Tag ¶
func (it *Introspector) Tag(fieldName string, tagName string) (tag string, isFieldFound bool)
Get tag by of field
func (*Introspector) TagRetriever ¶
func (it *Introspector) TagRetriever(fieldName string) (t TagRetriever, isFieldFound bool)
Get tag retriever for a field
type TagRetriever ¶
type WalkTagCallback ¶
Click to show internal directories.
Click to hide internal directories.