typevisit

package
v3.13.3 Latest Latest
Warning

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

Go to latest
Published: May 4, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidType  = errors.New("invalid-type")
	ErrInvalidValue = errors.New("invalid-value")
)

Functions

This section is empty.

Types

type FieldOpts

type FieldOpts string

type TargetVisitorFunc

type TargetVisitorFunc func(v reflect.Value, opts FieldOpts)

type TypeVisitorTree

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

func New

func New(rootType, targetType any, tagName string) (*TypeVisitorTree, error)

New constructs a tree that is tailored to visit all instances of the target type that are found below the root type the root type must be a pointer to a struct, the target type can be any type and tagName specifies a tag that will be searched for the tag string content on a struct field will be passed to the callback, if the field is a map of slice of array of pointer of map of target type, then the tag will still be passed along this will not work on non-exported or anonymous struct fields and pointer loops are not detected

func (TypeVisitorTree) Visit

func (tvt TypeVisitorTree) Visit(value any, targetVisitor TargetVisitorFunc) error

Visit must be called with the root type the tree was constructed for and will call the user callback on all target type instances

Jump to

Keyboard shortcuts

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