util

package
v0.0.0-...-95cb943 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2024 License: Apache-2.0, Apache-2.0 Imports: 10 Imported by: 0

README

util

常用小工具库(非依赖第三方库)

Documentation

Index

Constants

View Source
const (
	NULL = ""
)

Variables

This section is empty.

Functions

func CopyMap

func CopyMap[K comparable, V any](src map[K]V) (dst map[K]V)

func CopySlice

func CopySlice[T any](src []T) (dst []T)

func DeduplicateSlice

func DeduplicateSlice[T comparable](slice []T) (result []T)

数组去重

func FilterIntSlice

func FilterIntSlice(src []int, dst []int) (result []int)

Deprecated FilterIntSlice() is deprecated, please use FilterSlice() instead. 过滤数组,去除src在dst中存在的item src[1,2,3,4,5] dst[2,4,6,8] result[1,3,5]

func FilterSlice

func FilterSlice[T comparable](src, dst []T) (result []T)

过滤数组,去除src在dst中存在的item src[1,2,3,4,5] dst[2,4,6,8] result[1,3,5] src["a","b","c","d","e"] dst["b","d","f","h"] result["a","c","e"]

func FilterStringSlice

func FilterStringSlice(src []string, dst []string) (result []string)

Deprecated FilterStringSlice() is deprecated, please use FilterSlice() instead. 过滤数组,去除src在dst中存在的item src["a","b","c","d","e"] dst["b","d","f","h"] result["a","c","e"]

func FormatURLParam

func FormatURLParam(body map[string]any) (urlParam string)

func IntDeduplicate

func IntDeduplicate(slice []int) (result []int)

Deprecated IntDeduplicate() is deprecated, please use DeduplicateSlice() instead. int 数组去重

func IntIntersect

func IntIntersect(slice1, slice2 []int) (result []int)

Deprecated IntIntersect() is deprecated, please use IntersectSlice() instead. int 数组,slice1 和 slice2 交集

func IntMergeDeduplicate

func IntMergeDeduplicate(slice1, slice2 []int) (result []int)

Deprecated IntMergeDeduplicate() is deprecated, please use MergeDeduplicateSlice() instead. int 数组合并+去重

func IntRemoveElement

func IntRemoveElement(slice []int, elem, n int) (result []int)

Deprecated IntRemoveElement() is deprecated, please use RemoveSliceElement() instead. int 数组,移除元素 If n < 0, there is no limit on the number of remove. return new slice

func IntRemoveElementByIndex

func IntRemoveElementByIndex(slice []int, index int) (result []int)

Deprecated IntRemoveElementByIndex() is deprecated, please use RemoveSliceElementByIndex() instead. int 数组,根据index移除元素 return new slice

func IntUnion

func IntUnion(slice1, slice2 []int) (result []int)

Deprecated IntUnion() is deprecated, please use UnionSlice() instead. int 数组,slice1 和 slice2 并集

func IntersectSlice

func IntersectSlice[T comparable](slice1, slice2 []T) (result []T)

slice1 和 slice2 交集

func JoinInts

func JoinInts(is []int64) string

JoinInts format int64 slice like [1,2,3,4,5] to string like 1,2,3,4,5.

func MergeDeduplicateSlice

func MergeDeduplicateSlice[T comparable](slice1, slice2 []T) (result []T)

数组合并+去重

func RandomNumber

func RandomNumber(l int) string

随机生成数字字符串

func RandomPureString

func RandomPureString(l int) string

随机生成纯字符串

func RandomString

func RandomString(l int) string

随机生成字符串

func RemoveSliceElement

func RemoveSliceElement[T comparable](slice []T, elem T, n int) (result []T)

数组移除元素 If n < 0, there is no limit on the number of remove. return new slice

func RemoveSliceElementByIndex

func RemoveSliceElementByIndex[T comparable](slice []T, index int) (result []T)

数组根据index移除元素 return new slice

func SplitInts

func SplitInts(s string) ([]int64, error)

SplitInts split string like 1,2,3,4,5 into int64 slice like [1,2,3,4,5].

func StringDeduplicate

func StringDeduplicate(slice []string) (result []string)

Deprecated StringDeduplicate() is deprecated, please use DeduplicateSlice() instead. string 数组去重

func StringMergeDeduplicate

func StringMergeDeduplicate(slice1, slice2 []string) (result []string)

Deprecated StringMergeDeduplicate() is deprecated, please use MergeDeduplicateSlice() instead. string 数组合并+去重

func StringRemoveElement

func StringRemoveElement(slice []string, elem string, n int) (result []string)

Deprecated string 数组,移除元素 If n < 0, there is no limit on the number of remove. return new slice

func StringRemoveElementByIndex

func StringRemoveElementByIndex(slice []string, index int) (result []string)

Deprecated StringRemoveElementByIndex() is deprecated, please use RemoveSliceElementByIndex() instead. string 数组,根据index移除元素 return new slice

func UnionSlice

func UnionSlice[T comparable](slice1, slice2 []T) (result []T)

string 数组,slice1 和 slice2 并集

func VerifyIDCard

func VerifyIDCard(idCard string) bool

VerifyIDCard 计算规则参考“中国国家标准化管理委员会”官方文档:http://www.gb688.cn/bzgk/gb/newGbInfo?hcno=080D6FBF2BB468F9007657F26D60013E 身份证号码校验

func VerifyPhoneNumber

func VerifyPhoneNumber(phone string) bool

VerifyPhoneNumber 手机号码校验

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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