reflectutil

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsEmpty

func IsEmpty(v reflect.Value) bool

IsEmpty reports whether v should be treated as "empty" for omitempty semantics.

This is similar to encoding/json's emptiness rules but also treats structs (including nested structs) as empty when all fields are empty, and treats time.Time as empty when IsZero() is true.

Types

type LegacyAliasResolver added in v1.6.0

type LegacyAliasResolver func(field reflect.StructField) (aliases []string, skip bool, err error)

LegacyAliasResolver resolves the legacy container aliases that older helper surfaces used when anonymous embedded structs were encoded as nested maps.

When skip is true, no legacy container aliases are recorded for the field. This is useful for callers that treat tag-based skips (for example "-") as ineligible for compatibility lookup while still wanting the promoted leaf fields themselves to remain visible.

type LegacyContainerPlan added in v1.6.0

type LegacyContainerPlan struct {
	IndexPath []int
	Aliases   []string
	Field     reflect.StructField
}

LegacyContainerPlan records one anonymous embedded struct container on the path to a promoted visible field, along with the aliases legacy helper surfaces used for nested compatibility lookups.

type VisibleFieldPlan added in v1.6.0

type VisibleFieldPlan struct {
	IndexPath        []int
	LegacyContainers []LegacyContainerPlan
	Field            reflect.StructField
}

VisibleFieldPlan describes one exported visible field on a struct, including promoted fields that arrived through exported anonymous embedded structs. Anonymous struct containers themselves are intentionally omitted.

func BuildVisibleFieldPlan added in v1.6.0

func BuildVisibleFieldPlan(modelType reflect.Type, aliasResolver LegacyAliasResolver) ([]VisibleFieldPlan, error)

BuildVisibleFieldPlan enumerates exported visible fields for a struct using Go promotion rules. Promoted fields are included only when they arrive through exported anonymous embedded structs, matching TableTheory's current metadata recursion scope. Anonymous struct containers themselves are omitted.

Jump to

Keyboard shortcuts

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