Documentation ¶
Index ¶
- func GetMapField[TData any, TKey comparable](mapval any, key TKey) (TData, bool)
- func GetMapPath[TData any](mapval any, path string) (TData, bool)
- func TryCast[T any](v any) (T, bool)
- func TryCastType(v any, dest reflect.Type) (any, bool)
- func Underlying(t reflect.Type) (ret reflect.Type)
- type PrimitiveStringSerializer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetMapField ¶ added in v0.0.367
func GetMapField[TData any, TKey comparable](mapval any, key TKey) (TData, bool)
GetMapField gets the value of a map, without knowing the actual types (mapval is any) eg: x := langext.H{"K1": 665} GetMapPath[int](x, "K1") == 665
works with aliased types and autom. dereferences pointes
func GetMapPath ¶ added in v0.0.367
GetMapPath returns the value deep inside a hierahically nested map structure eg: x := langext.H{"K1": langext.H{"K2": 665}} GetMapPath[int](x, "K1.K2") == 665
func Underlying ¶
Underlying returns the underlying type of t (without type alias)
https://github.com/golang/go/issues/39574#issuecomment-655664772
Types ¶
type PrimitiveStringSerializer ¶
type PrimitiveStringSerializer struct{}
PrimitiveStringSerializer is used to serialize primitive types (and a few more) from and to string This is not really intended to be user facing, and more as a simple building block for other mechanisms supports:
- golang primitives (ints, uints, floats, bool, string)
- type aliases
- time.Time
- primitive.ObjectID
func (PrimitiveStringSerializer) ValueFromString ¶
func (PrimitiveStringSerializer) ValueToString ¶
func (pss PrimitiveStringSerializer) ValueToString(v any) (string, error)