Documentation ¶
Overview ¶
Package convertor implements some functions to convert data.
Index ¶
- func ColorHexToRGB(colorHex string) (red, green, blue int)
- func ColorRGBToHex(red, green, blue int) string
- func MapToSlice[T any, K comparable, V any](aMap map[K]V, iteratee func(K, V) T) []T
- func StructToMap(value any) (map[string]any, error)
- func ToBool(s string) (bool, error)
- func ToBytes(value any) ([]byte, error)
- func ToChannel[T any](array []T) <-chan T
- func ToChar(s string) []string
- func ToFloat(value any) (float64, error)
- func ToInt(value any) (int64, error)
- func ToJson(value any) (string, error)
- func ToMap[T any, K comparable, V any](array []T, iteratee func(T) (K, V)) map[K]V
- func ToPointer[T any](value T) *T
- func ToString(value any) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ColorHexToRGB ¶
ColorHexToRGB convert hex color to rgb color
func ColorRGBToHex ¶
ColorRGBToHex convert rgb color to hex color
func MapToSlice ¶ added in v2.1.2
func MapToSlice[T any, K comparable, V any](aMap map[K]V, iteratee func(K, V) T) []T
MapToSlice convert a map to a slice based on iteratee function
func StructToMap ¶
StructToMap convert struct to map, only convert exported struct field map key is specified same as struct field tag `json` value
func ToChannel ¶ added in v2.1.2
func ToChannel[T any](array []T) <-chan T
ToChannel convert a array of elements to a read-only channels
func ToMap ¶ added in v2.1.2
func ToMap[T any, K comparable, V any](array []T, iteratee func(T) (K, V)) map[K]V
ToMap convert a slice or an array of structs to a map based on iteratee function
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.