Documentation
¶
Index ¶
- Variables
- func Base64Decode(str string) (string, error)
- func Base64Encode(str string) string
- func CastInterfaceSlice[T any](slice []interface{}) ([]T, error)
- func ConvertMapToTypedMap[K ~string, V any](raw interface{}) map[K]V
- func ConvertToInterfaceSlice[T any](ids []T) []interface{}
- func ConvertToMapInterface(m map[string]interface{}) map[interface{}]interface{}
- func ConvertToMapStringInterface(m map[interface{}]interface{}) map[string]interface{}
- func CopyStructFieldsRecursive(dst interface{}, src interface{})
- func CreateChunks(s []interface{}, size int) ([][]interface{}, error)
- func ExistsInList(val interface{}, array interface{}) (bool, int)
- func GetCryptoSafeRandomString(length uint8) (string, error)
- func GetFunctionName(f interface{}) string
- func GetRandomString(length int64) string
- func IsASCII(s string) bool
- func IsEmpty(value interface{}) bool
- func IsNumber(value interface{}) bool
- func MaxInt64(a, b int64) int64
- func MaxUint8(a, b uint8) uint8
- func MaxUint64(a, b uint64) uint64
- func MergeMaps[T any](map1, map2 map[string]T) map[string]T
- func NullableString(value interface{}) string
- func PackNumbers(num1 int32, num2 int32) int64
- func PopulateStructFromMap(dst interface{}, src map[string]interface{}) error
- func StructToMap(data interface{}) (map[string]interface{}, error)
- func ToBool(value interface{}) (bool, error)
- func ToFloat32(value interface{}) (float32, error)
- func ToFloat64(value interface{}) (float64, error)
- func ToInt(value interface{}) (int, error)
- func ToInt64(value interface{}) (int64, error)
- func ToInterfaceSlice(strings []string) []interface{}
- func ToString(arg interface{}, timeFormat ...string) string
- func UCFirst(value string) string
- func UnmarshalCustom(data []byte, out interface{}) error
- func UnpackFirstNumber(packed int64) int32
- func UnpackNumbers(packed int64) (int32, int32)
- func UnpackSecondNumber(packed int64) int32
Constants ¶
This section is empty.
Variables ¶
var NumberTypes = []reflect.Kind{ reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int32, reflect.Int64, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Int32, reflect.Int64, reflect.Float32, reflect.Float64, }
List of all valid numeric datatypes in GoLang
Functions ¶
func Base64Decode ¶
Decodes base64 string and return the decoded value
func Base64Encode ¶
Encodes input value into base64 encoded string
func CastInterfaceSlice ¶
CastInterfaceSlice converts a slice of interfaces to a slice of type T. It returns an error if any item cannot be converted to T.
func ConvertMapToTypedMap ¶
convertMapToTypedMap converts a map[string]V or map[string]interface{} to map[K]V
func ConvertToInterfaceSlice ¶
func ConvertToInterfaceSlice[T any](ids []T) []interface{}
func ConvertToMapInterface ¶
func ConvertToMapInterface(m map[string]interface{}) map[interface{}]interface{}
ConvertToMapInterface converts a map with string keys to a map with interface{} keys.
func ConvertToMapStringInterface ¶
func ConvertToMapStringInterface(m map[interface{}]interface{}) map[string]interface{}
ConvertToMapStringInterface converts a map with interface{} keys to a map with string keys.
func CopyStructFieldsRecursive ¶
func CopyStructFieldsRecursive(dst interface{}, src interface{})
CopyStructFieldsRecursive copies fields from one struct to another recursively.
func CreateChunks ¶
Create 2 dimensional chunked array from the provided one dimensional array/list of elements, as each chunk of size n provided as `size` parameter.
Example:
Input = [1,2,3,4,5,6] Size = 2 Output = [[1,2], [3,4], [5,6]]
func ExistsInList ¶
ExistsInList checks if a given value exists within a slice and returns a boolean indicating its existence and the index at which it was found.
Parameters:
- val: The value to search for in the slice.
- array: The slice to search within.
Returns:
- exists: A boolean value indicating whether 'val' exists in 'array'.
- index: An integer representing the index where 'val' was found in 'array'. If 'val' is not found, the index is set to -1.
func GetCryptoSafeRandomString ¶
GetCryptoSafeRandomString generates a random string of the specified length using the crypto/rand package. The string is URL-safe and does not contain any padding characters.
func GetFunctionName ¶
func GetFunctionName(f interface{}) string
GetFunctionName takes a function pointer and returns its fully qualified name.
It uses reflection to get the function pointer, then uses the runtime package to retrieve the function information, and finally returns the fully qualified function name.
Parameters: - f: The function pointer.
Returns: - string: The fully qualified name of the function.
func GetRandomString ¶
GetRandomString generates a random string of the specified length.
func IsNumber ¶
func IsNumber(value interface{}) bool
Checks if the provided variable is a number. The number can be any of type, ie signed int, unsigned int or float.
func NullableString ¶
func NullableString(value interface{}) string
NullableString converts an interface{} to a string. returning an empty string if the value is nil or not a string.
func PackNumbers ¶
func PopulateStructFromMap ¶
func StructToMap ¶
func ToInterfaceSlice ¶
func ToInterfaceSlice(strings []string) []interface{}
takes string slice as an input and convert that into more generic slice of interface{}
func UnmarshalCustom ¶
Generalized Unmarshal Function
func UnpackFirstNumber ¶
Get only the first number from the packed uint64
func UnpackNumbers ¶
Unpack both numbers from the packed uint64
func UnpackSecondNumber ¶
Get only the second number from the packed uint64
Types ¶
This section is empty.