utils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AND

func AND(ands ...bool) bool

func ArrayInterfaceToString

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

func ArrayToMapInt8

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

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(dict map[string]interface{}, key string, defaultValue interface{}) interface{}

func IfE

func IfE(expr bool, then func(), el func())

func IfER

func IfER[T any](expr bool, then func() T, el func() T) T

func IfEmpty

func IfEmpty[T string | int](value T, whenEmpty T) T

func IfErrorThen

func IfErrorThen(err error, run func())

func IfNil

func IfNil[T string | int | *time.Time | map[string]interface{}](value interface{}, whenNil T) T

func IfNotEmpty

func IfNotEmpty[T string | int](value T, whenNotEmpty T) T

func IfR

func IfR[T *any](expr bool, run func() T) T

func IfRE

func IfRE[T *any](expr bool, run func() (T, error)) (T, error)

func IfTrueThen

func IfTrueThen(expr bool, run func())

func Iif

func Iif[T any](expr bool, whenTrue, whenFalse T) T

func InArray

func InArray[T string | int | int64 | uint | uint64 | float32 | float64](arr []T, v T) bool

func IntToString

func IntToString(v int) string

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 OR

func OR(ors ...bool) bool

func SliceItems

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

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 ValueOnMap

func ValueOnMap[T string | int | int64 | float64 | interface{}](dict map[string]T, key string, defaultValue T) T

func ValueOnMapByKey

func ValueOnMapByKey[T any](dict map[string]T, key string, defaultValue 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