Documentation
¶
Index ¶
- func GetDefaultValue[T any](data map[string]any, key string, defaultValue T) T
- func NewInstance[T any]() T
- func PtrOf[T any](v T) *T
- func Reverse[S ~[]E, E any](s S) S
- func Set[T comparable]() *set[T]
- func ToOptional[T any](value any) *T
- func ToSliceOfInt(input any) ([]int, error)
- func ToStringMap(inputMap map[string]any) map[string]string
- func TypeOf[T any]() reflect.Type
- type Pair
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetDefaultValue ¶ added in v0.1.3
GetDefaultValue returns the default value if the key is not found in the data Example: GetDefaultValue(data, "headless", false)
func NewInstance ¶ added in v0.1.3
func NewInstance[T any]() T
NewInstance create an instance of the given type T. the main purpose of this function is to create an instance of a type, can handle the type of T is a pointer or not. eg. NewInstance[int] returns 0. eg. NewInstance[*int] returns *0 (will be ptr of 0, not nil!).
func PtrOf ¶ added in v0.1.3
func PtrOf[T any](v T) *T
PtrOf returns a pointer of T. useful when you want to get a pointer of a value, in some config, for example. eg. PtrOf[int] returns *int. eg. PtrOf[*int] returns **int.
func Reverse ¶ added in v0.1.3
func Reverse[S ~[]E, E any](s S) S
Reverse returns a new slice with elements in reversed order.
func ToOptional ¶ added in v0.1.3
func ToSliceOfInt ¶ added in v0.1.3
func ToStringMap ¶ added in v0.1.3
ToStringMap converts a map[string]any to map[string]string. It iterates through the input map and includes only the key-value pairs where the value is of type string.