Documentation
¶
Overview ¶
Package common provides various helper functions
Package common provides various helper functions
Index ¶
- func GetMainCtxCancel() (context.Context, context.CancelFunc)
- func GetSliceOfStringMap(slice []interface{}) ([]map[string]string, error)
- func StringSliceTransform(values []string, fct func(string) string) []string
- func StructToMap(obj interface{}) map[string]interface{}
- func ToPowerOf2(x int) int
- type StringSet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetMainCtxCancel ¶ added in v0.51.0
func GetMainCtxCancel() (context.Context, context.CancelFunc)
GetMainCtxCancel will return the main context and cancel function and populate them the main context can only be populated once
func GetSliceOfStringMap ¶ added in v0.58.0
GetSliceOfStringMap is a utility function that returns a config key expected to be a slice of map[string]interface{} as a slice of map[string]string, assuming the underlying types can be cast to string.
func StringSliceTransform ¶
StringSliceTransform returns a new slice `s` where s[i] = fct(values[i])
func StructToMap ¶
func StructToMap(obj interface{}) map[string]interface{}
StructToMap converts a struct to a map[string]interface{} based on `json` annotations defaulting to field names
func ToPowerOf2 ¶ added in v0.73.0
ToPowerOf2 converts a number to its nearest power of 2
Types ¶
type StringSet ¶
type StringSet map[string]struct{}
StringSet represents a list of uniq strings
func NewStringSet ¶
NewStringSet returns as new StringSet initialized with initItems