reflectvisitor

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OptSetter

type OptSetter struct {
	Value *reflect.Value
	IsSet reflect.Value
}

type Visitor

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

func NewVisitor

func NewVisitor(root reflect.Type) *Visitor

func (*Visitor) Visit

func (v *Visitor) Visit(rootInstance *reflect.Value, f func(t Walker[reflect.Type]) []Walker[reflect.Type])

Visit traverses the structure of the provided rootInstance using reflection, starting from the type stored in the Visitor. It applies the user-provided function f to each struct type encountered, allowing custom logic to generate additional types to visit. The traversal handles optional types (structs with names prefixed by "Opt") by mapping their "Value" field to the underlying type and supports indirect pointer dereferencing. The function f receives a Walker containing the current type, a string prefix, and an OptSetter representing the value being visited. The traversal continues as long as f returns additional Walker instances to process.

type Walker

type Walker[T any] struct {
	T1             T
	T2             string
	OptionalSetter OptSetter
}

Jump to

Keyboard shortcuts

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