util

package
v1.5.5 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2023 License: Apache-2.0 Imports: 7 Imported by: 5

Documentation

Overview

Package util

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Any2Any added in v1.3.1

func Any2Any(raw any, target any) error

Any2Any 数据结构转换

func Any2JSON added in v1.3.1

func Any2JSON(i any) (string, error)

func Any2String added in v1.3.1

func Any2String(v any) (ret string)

Any2String 任意数据转string

func ArrSplit

func ArrSplit[T any](arr []T, batchSize int) [][]T

ArrSplit 按照给定的子数组长度进行数组切分,返回二维数组

func BoolToStr

func BoolToStr(b bool) string

func Cast added in v1.3.1

func Cast[T any](raw any) (*T, error)

func CharMerge

func CharMerge[T char](s string, ch T) []T

CharMerge 合并字符串中相邻的多个指定的字符

func Difference

func Difference[T comparable](arr1 []T, arr2 []T) []T

Difference 差集

func ElemIn

func ElemIn[T comparable](target T, arr []T) bool

ElemIn 判断数据是否在数组中

func EndWith

func EndWith(s string, sub string, ignoreCase bool) (found bool)

func FloatToStr

func FloatToStr[T floatType](f T) string

func GetMapValue

func GetMapValue[K comparable, V any](raw map[K]V, key K, def V) V

GetMapValue 获取map数据

func HumpFormatToUnderLine

func HumpFormatToUnderLine(s string) string

HumpFormatToUnderLine 驼峰转下划线命名

func IntToStr

func IntToStr[T intType](i T) string

func Intersection

func Intersection[T comparable](arr1 []T, arr2 []T) []T

Intersection 交集

func JoinArr

func JoinArr[T any](arr []T, linkStr string) string

JoinArr 链接数组

func Map2Bytes

func Map2Bytes[K comparable, V any](m map[K]V) ([]byte, error)

func Map2JSON

func Map2JSON[K comparable, V any](m map[K]V) (string, error)

func MapHumpFormatToUnderLine

func MapHumpFormatToUnderLine[V any](raw map[string]V) map[string]V

MapHumpFormatToUnderLine map key 驼峰转下滑线命名

func MergeMap

func MergeMap[K comparable, V any](data ...map[K]V) map[K]V

MergeMap 合并map

func NumArrTransfer

func NumArrTransfer[T1 numType, T2 numType](arr []T1) []T2

NumArrTransfer 数字型的数组转换

func ParamsSorted

func ParamsSorted[V any](params map[string]V) string

ParamsSorted 参数计算排序字符串

func RandomInt64

func RandomInt64(min, max int64) int64

RandomInt64 returns, as an int64, a non-negative pseudo-random number in the half-open interval [min,max)

func SafeGo

func SafeGo(f func())

func StartWith

func StartWith(s string, sub string, ignoreCase bool) (found bool)

func Str2Bool

func Str2Bool(s string) (bool, error)

func Str2Float

func Str2Float[T floatType](s string) (T, error)

func Str2FloatArr

func Str2FloatArr[T floatType](s string, sep string) ([]T, error)

func Str2Int

func Str2Int[T intType](s string) (T, error)

func Str2IntArr

func Str2IntArr[T intType](s string, sep string) ([]T, error)

func Str2Uint

func Str2Uint[T uintType](s string) (T, error)

func StrSplit

func StrSplit(s string, seq []string, trimSpace bool) ([]string, []string)

StrSplit 多分隔符切分字符串 返回拆分的字符串数组以及实际的分割标识数组

func UintToStr

func UintToStr[T uintType](i T) string

func Union

func Union[T comparable](arr1 []T, arr2 []T) []T

Union 并集

Types

This section is empty.

Jump to

Keyboard shortcuts

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