Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetStructValue ¶
func GetStructValue(v any, fieldName string, opts ...StructValueOption) any
GetStructValue retrieves a value from `v`. The type of `v` MUST be a struct, otherwise returns nil.
Use StructValueOption derivatives (e.g. WithTag, WithTagSeparator) to customize how this routine handles edge cases.
Types ¶
type StructValueOption ¶
type StructValueOption func(*structValueOptions)
StructValueOption is a routine used to specify configurations to GetStructValue.
func WithTag ¶
func WithTag(t string) StructValueOption
WithTag indicates the tag to use as fallback during GetStructValue execution.
GetStructValue will split the tag by `,` (or the one provided if used WithTagSeparator) if it defines multi-values (e.g. `foo:"bar,baz"`) and will use the first value provided.
func WithTagSeparator ¶
func WithTagSeparator(s string) StructValueOption
WithTagSeparator indicates the tag separator pattern to split tag (provided by WithTag).
`,` will be used as default if no pattern provided.