utils

package
v0.0.0-...-055c042 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindBalanceDecimalPlace

func FindBalanceDecimalPlace(text string) (decimalPlace int, intPart string, fractionalPart string, err error)

func GetFunctionName

func GetFunctionName(i interface{}) string

func GroupBy

func GroupBy[T any, KEY comparable](items []T, keyGetter func(*T) KEY) map[KEY][]T

func GroupByWithSize

func GroupByWithSize[T any, KEY comparable](items []T, keyGetter func(*T) KEY, groupSize int) (
	groupMap map[KEY][]T,
)

func IntersecArea

func IntersecArea(rect1, rect2 []float64) float64

func IsWordInText

func IsWordInText(text string, words ...string) bool

func LevenshteinPercentage

func LevenshteinPercentage(s1, s2 string) float64

func ListFilter

func ListFilter[E any](items []E, filterFn func(i int, e E) bool) []E

func ListFilterPointer

func ListFilterPointer[E any](items []E, filterFn func(i int, e *E) bool) []E

func ListFindFirst

func ListFindFirst[T any](items []T, matchFn func(e T) bool) (_ T, ok bool)

func ListMap

func ListMap[S any, D any](items []S, mapFn func(i int, e S) D) []D

func ListMapPointer

func ListMapPointer[S any, D any](items []S, mapFn func(i int, e *S) D) []D

func ListMapWithError

func ListMapWithError[S any, D any](items []S, mapFn func(i int, e S) (D, error)) ([]D, error)

func ListMerge

func ListMerge[T any](lists ...[]T) []T

func ListReduce

func ListReduce[E any, AGG any](items []E, initValue AGG, reduceFn func(result AGG, e E) AGG) AGG

func ListReducePointer

func ListReducePointer[E any, AGG any](items []E, initValue AGG, reduceFn func(result AGG, e *E) AGG) AGG

func ListToMap

func ListToMap[E any, K comparable, V any](items []E, mapFn func(i int, e E) (K, V)) map[K]V

func ListToMapPointer

func ListToMapPointer[S any, K comparable, V any](items []S, mapFn func(i int, e *S) (K, V)) map[K]V

func MapKeys

func MapKeys[K comparable, V any](m map[K]any) []K

func MapToList

func MapToList[K comparable, V any, E any](m map[K]V, mapFn func(k K, v V) E) []E

func MapUpdate

func MapUpdate[K comparable, V any](left map[K]V, right map[K]V) map[K]V

MapUpdate updates the data from the right map to the left one.

func MapValues

func MapValues[K comparable, V any](m map[K]V) []V

func NormalizeBalance

func NormalizeBalance(text string) (balance decimal.Decimal, err error)

func NormalizeString

func NormalizeString(text string) (result string)

func NormalizeVietnamese

func NormalizeVietnamese(text string) (result string)

func NormalizeVietnameseName

func NormalizeVietnameseName(text string) (result string)

func PanicOnError

func PanicOnError(err error)

func ParallelRun

func ParallelRun(ctx context.Context, size int, processor ...func(ctx context.Context) error) (err error)

func ParallelRunGlobal

func ParallelRunGlobal(ctx context.Context, size int, processor ...func(ctx context.Context) error) (err error)

func ReactSquare

func ReactSquare(rect []float64) float64

func RectIOU

func RectIOU(rect1, rect2 []float64) float64

func RemoveCurrencyIndicators

func RemoveCurrencyIndicators(text string) string

func ReplaceAcronyms

func ReplaceAcronyms(text string) string

func Stringify

func Stringify(v any) string

func ToError

func ToError(v any) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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