Documentation ¶
Index ¶
- func GetStructFieldValue[T any](s T, tagValue string, tagName string) (reflect.Value, bool)
- func GetTime(v any) (time.Time, bool)
- func GetType(s any) reflect.Type
- func GetValue(s any) reflect.Value
- func MapToStruct[T any](m map[string]string, tagName string) T
- func StructToMap[T any](s T, tagName string) map[string]any
- func ToString(value any) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetStructFieldValue ¶
GetStructFieldValue returns the reflect.Value corresponding to the field of struct T whose field has a tag tagName with value tagValue.
For example, given this struct and var declaration:
type S struct { Foo string `slug:"foo" Bar string `slug:"bar" } var s S
GetStructFieldValue(&s, "foo", "slug") will return the reflect.Value corresponding to s.Foo.
func GetTime ¶
GetTime returns the time.Time that corresponds to the passed value. The value must be either time.Time or sql.Null[time.Time].
func MapToStruct ¶
MapToStruct converts a map[string]string into a struct T using values from tag tagName as the keys.
func StructToMap ¶
StructToMap converts struct T into a map[string]any using values from tag tagName as the keys.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.