structs

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

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.

Jump to

Keyboard shortcuts

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