reflect

package
v0.0.0-...-634ea66 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssignToField

func AssignToField[T any](obj *T, fieldName string, stringEncodedValue string) error

AssignToField sets a struct field specified by its name to a provided value encoded as a string. The function handles various data types including basic types (string, int, etc.), complex types (structs, slices, maps) and types implementing the encoding.TextUnmarshaler interface. The conversion from string to the appropriate type is performed based on the field's underlying type. JSON format is expected for complex types. This function supports setting both direct values and pointers to the values.

func FieldsToMetadata

func FieldsToMetadata[T any]() *readonlymap.ReadOnlyMap[string, *FieldMetadata]

FieldsToMetadata returns a map of a structs field names to their respective metadata.

Types

type FieldMetadata

type FieldMetadata struct {
	Type      reflect.Type
	Tags      map[string]string
	Anonymous []string
}

FieldMetadata is the metadata extracted from struct fields.

Jump to

Keyboard shortcuts

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