Help us shape the future of Go! Take the 2026 Go Developer Survey

structs

package
v0.11.9 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 4 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterStruct added in v0.4.11

func FilterStruct[T any](input T, includeFields, excludeFields []string) (T, error)

FilterStruct filters the struct based on include and exclude fields and returns a new struct. - input: the original struct. - includeFields: list of fields to include (if empty, includes all). - excludeFields: list of fields to exclude (processed after include).

func FilterStructToMap added in v0.5.0

func FilterStructToMap[T any](input T, includeFields, excludeFields []string) (*mapsutil.OrderedMap[string, any], error)

func GetStructFields added in v0.4.11

func GetStructFields[T any](input T) ([]string, error)

GetStructFields returns all the top-level field names from the given struct. - input: the original struct. Returns a slice of field names or an error if the input is not a struct.

func Walk

func Walk(s interface{}, callback CallbackFunc)

Walk traverses a struct and executes a callback function on each field in the struct. The interface{} passed to the function should be a pointer to a struct

Types

type CallbackFunc

type CallbackFunc func(reflect.Value, reflect.StructField)

CallbackFunc on the struct field example: structValue := reflect.ValueOf(s) ... field := structValue.Field(i) fieldType := structValue.Type().Field(i)

Jump to

Keyboard shortcuts

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