reflectx

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 21, 2025 License: MIT, MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustBeStruct

func MustBeStruct(s any)

MustBeStruct panics if the given value is a struct or a pointer to a struct.

Types

type FieldIndexContainer

type FieldIndexContainer []uint16

func NewFieldIndexContainer

func NewFieldIndexContainer(n int) FieldIndexContainer

func (*FieldIndexContainer) Add

func (fic *FieldIndexContainer) Add(fieldPath []int)

func (FieldIndexContainer) Cap

func (f FieldIndexContainer) Cap() int

func (FieldIndexContainer) Len

func (f FieldIndexContainer) Len() int

func (FieldIndexContainer) RangeByFieldPath

func (f FieldIndexContainer) RangeByFieldPath(columnPos []int, fn func(fieldPath []uint16))

type PointerSlicePool

type PointerSlicePool[T any] struct {
	// contains filtered or unexported fields
}

func NewPointerSlicePool

func NewPointerSlicePool[T any](fic FieldIndexContainer) *PointerSlicePool[T]

func (*PointerSlicePool[T]) Release

func (p *PointerSlicePool[T]) Release(s *[]any)

func (*PointerSlicePool[T]) StructFieldPtrs

func (p *PointerSlicePool[T]) StructFieldPtrs(v *T, scopeColIndexes []int) *[]any

type StructField

type StructField struct {
	// Path is the path to the field in the struct hierarchy.
	// It is represented as a slice of integers, where each integer is the index
	// of the field in the parent struct.
	Path []int
	// Name is the name of the field.
	Name string
	// Tag is the value of the struct tag.
	Tag string
}

StructField represents a field in a struct.

func ExtractStructFields

func ExtractStructFields(ptrToStruct any, tag string) []StructField

ExtractStructFields extracts fields from a struct or a pointer to a struct.

It returns a slice of StructField, which contains the field name, tag value, and the path to the field in the struct hierarchy. The tag parameter specifies the struct tag to look for. The function panics if the input is not a struct or a pointer to a struct. The function does not include unexported fields and fields with a tag value of "-". It also handles embedded structs and nested structs. The path is represented as a slice of integers, where each integer is the index of the field in the parent struct.

type TagPairs

type TagPairs map[string][]string

TagPairs represents a map of key-value pairs.

func NewTagPairs

func NewTagPairs() TagPairs

NewTagPairs creates a new TagPairs instance.

func ParseTagPairs

func ParseTagPairs(tag string, scopeTagKey string) TagPairs

ParseTagPairs parses a tag string into TagPairsX.

func (*TagPairs) Add

func (tp *TagPairs) Add(key, value string)

Add adds a new key-value pair to the TagPairsX.

func (TagPairs) Exist

func (tp TagPairs) Exist(key string) bool

Exist checks if the given key exists in the TagPairsX.

func (*TagPairs) Get

func (tp *TagPairs) Get(key string) []string

Get retrieves all values associated with the given key.

func (TagPairs) PairExist

func (tp TagPairs) PairExist(key, val string) bool

PairExist checks if the given key-value pair exists in the TagPairsX.

func (*TagPairs) Value

func (tp *TagPairs) Value(key string) string

Value retrieves the first value associated with the given key.

Jump to

Keyboard shortcuts

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