utils

package
v0.3.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrayInterfaceToString

func ArrayInterfaceToString(arr []interface{}) []string

func ArrayToMapInt8

func ArrayToMapInt8(arrOfString []string) map[string]int8

func Atoi added in v0.3.0

func Atoi(b []byte) (int, error)

func BytesToString added in v0.3.0

func BytesToString(b []byte) string

func BytesToStringUnsafe added in v0.3.0

func BytesToStringUnsafe(b []byte) string

BytesToStringUnsafe converts byte slice to string.

func CastToBool

func CastToBool(v interface{}, defaultValue bool) bool

func CastToBoolND

func CastToBoolND(v interface{}) bool

func CastToFloat64

func CastToFloat64(v interface{}, defaultValue float64) float64

func CastToFloat64ND

func CastToFloat64ND(v interface{}) float64

func CastToInt

func CastToInt(v interface{}, defaultValue int) int

func CastToInt64

func CastToInt64(v interface{}, defaultValue int64) int64

func CastToInt64ND

func CastToInt64ND(v interface{}) int64

func CastToIntND

func CastToIntND(v interface{}) int

func CastToMapInterface

func CastToMapInterface(v interface{}, defaultValue map[string]interface{}) map[string]interface{}

func CastToMapString

func CastToMapString(v interface{}, defaultValue map[string]string) map[string]string

func CastToMapStringND

func CastToMapStringND(v interface{}) map[string]string

func CastToString

func CastToString(v interface{}, defaultValue string) string

func CastToStringND

func CastToStringND(v interface{}) string

func CastToStruct

func CastToStruct[T any](v interface{}, defaultValue T) T

func CastToStructND

func CastToStructND[T any](v interface{}, result func(T)) error

func FindByInMapArray

func FindByInMapArray[T string | int | bool](field string, value T, collection []map[string]interface{}) map[string]interface{}

func Float64ToString

func Float64ToString(v float64) string

func GetItemFromMapArray

func GetItemFromMapArray(mapArray []map[string]interface{}, filter func(item map[string]interface{}) bool) map[string]interface{}

func GetValueOnMap

func GetValueOnMap[K comparable, V any](dict map[K]V, key K, defaultValue V) V

func InArray

func InArray[T comparable](arr []T, v T) bool

func IntToString

func IntToString(v int) string

func KeyExistsInMap added in v0.3.0

func KeyExistsInMap[K comparable, V any](m map[K]V, key K) bool

func MapInterfaceToMapString

func MapInterfaceToMapString(src map[string]interface{}) map[string]string

func MapMerge

func MapMerge[T string | int8 | int16 | int32 | int | interface{}](src map[string]T, dst map[string]T) map[string]T

func MapToStringArray

func MapToStringArray(value map[string]interface{}, format, separator string) string

func MergeContextWithCancel

func MergeContextWithCancel(c1, c2 context.Context) (context.Context, context.CancelFunc)

func NumberInRange added in v0.3.0

func NumberInRange[T common.IntegerAll | common.Float](v T, min T, max T) bool

func NumberInRangeEx added in v0.3.0

func NumberInRangeEx[T common.IntegerAll | common.Float](v T, min T, max T) bool

func ParseFloat added in v0.3.0

func ParseFloat(b []byte, bitSize int) (float64, error)

func ParseInt added in v0.3.0

func ParseInt(b []byte, base int, bitSize int) (int64, error)

func ParseUint added in v0.3.0

func ParseUint(b []byte, base int, bitSize int) (uint64, error)

func SliceItems

func SliceItems[T any](items []T, page, limit int) []T

func StringToBytes added in v0.3.0

func StringToBytes(s string) []byte

func StringToBytesUnsafe added in v0.3.0

func StringToBytesUnsafe(s string) []byte

StringToBytesUnsafe converts string to byte slice.

func StringToInt

func StringToInt(v string) int

func StringToIntDV

func StringToIntDV(v string, dv int) int

func ToArrayOfInterface

func ToArrayOfInterface[T string | int | int64 | float32 | float64](arrays []T) []interface{}

func ToMapInterface

func ToMapInterface(src interface{}) map[string]interface{}

func ToPtr added in v0.3.0

func ToPtr[T any](v T) *T

func ToStruct added in v0.3.0

func ToStruct[T any](src interface{}, dst *T) *T

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL