reflecto

package
v0.0.0-...-2d29fd2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ForEachFieldOptions = &forEachFieldConfig{}

Functions

func ForEachField

func ForEachField(target any, fn FieldHandler, options ...forEachFieldOption) (err error)

func GetSliceElementType

func GetSliceElementType(slice any) (reflect.Type, error)

func IsFieldExported

func IsFieldExported(fieldType reflect.StructField) bool

IsFieldExported returns whether a field are exported @see go/src/reflect/type.go reflect.StructField

func SliceContains

func SliceContains(slice any, target any) bool

func ToWriteableSliceValue

func ToWriteableSliceValue(slicePointer any) (*reflect.Value, error)

Types

type FieldContext

type FieldContext struct {
	Value *reflect.Value
	reflect.StructField
	Path string
}

type FieldHandler

type FieldHandler func(ctx FieldContext) error

type Iterator

type Iterator func() (any, error)

func (Iterator) Next

func (itr Iterator) Next() (any, error)

func (Iterator) WriteTo

func (itr Iterator) WriteTo(slicePointer any, handler ...any) (err error)

type ItrExitValidator

type ItrExitValidator func(iv any, err error) (bool, error)

type ItrMapper

type ItrMapper func(iv any) (any, error)

type ItrReducer

type ItrReducer func(iv any, in any) (any, error)

type SlicePtrReflector

type SlicePtrReflector struct {
	// contains filtered or unexported fields
}

func NewSlicePtrReflector

func NewSlicePtrReflector(slicePtr any) (*SlicePtrReflector, error)

func (*SlicePtrReflector) ItemType

func (ptrRef *SlicePtrReflector) ItemType() reflect.Type

func (*SlicePtrReflector) Len

func (ptrRef *SlicePtrReflector) Len() int

func (*SlicePtrReflector) Ptr

func (ptrRef *SlicePtrReflector) Ptr() int

func (*SlicePtrReflector) Read

func (ptrRef *SlicePtrReflector) Read(i int, outPtr any) error

type Spawner

type Spawner[T any] func() T

func NewAnySpawner

func NewAnySpawner(model any) (spawner Spawner[any])

func NewAnySpawnerFromType

func NewAnySpawnerFromType(ty reflect.Type) (spawner Spawner[any])

func NewTSpawner

func NewTSpawner[T any](model T) (spawner Spawner[T])

func (Spawner[T]) Spawn

func (sp Spawner[T]) Spawn() T

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL