utils

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseDecimalToN

func BaseDecimalToN(num int, baseN int) string

把10进制转N进制 baseN最大56,24存小写字母,32为数字和小写大于32大小字符

func BaseNToDecimal

func BaseNToDecimal(baseNum string, baseN int) int

把N进制转10进制 baseN最大56,24存小写字母,32为数字和小写大于32大小字符

func BytesToInt

func BytesToInt(bys []byte) int

*

  • 比特数组转int

func CamelCase

func CamelCase(s string) string

*

  • 蛇形转驼峰
  • @description xx_yy to XxYx xx_y_y to XxYY
  • @date 2023/10/13
  • @param s要转换的字符串
  • @return string *

func Deduplicate

func Deduplicate(array []any) []any

使用空接口实现数组去重

func DeduplicateString

func DeduplicateString(array []string) []string

*

  • 字符串素组去重

func GenUUid

func GenUUid() string

生成无-的uuid

func GetInterfaceToInt

func GetInterfaceToInt(t1 any) int

结构体转int

func GetReqId

func GetReqId(c *gin.Context) string

func IntToBytes

func IntToBytes(n int) []byte

*

  • int转比特数组

func InterfaceToStrArray

func InterfaceToStrArray(interfaceArr []any) []string

结构体转string数组

func InterfaceToStruct

func InterfaceToStruct(i1 any, i2 *any) error

interface 转结构体

func MaskSensitiveInfo

func MaskSensitiveInfo(s string, start int, maskNumber int, maskChars ...string) string

MaskSensitiveInfo 对于字符串脱敏 s 需要脱敏的字符串 start 从第几位开始脱敏 maskNumber 需要脱敏长度 maskChars 掩饰字符串,替代需要脱敏处理的字符串

func RandFloat

func RandFloat(min int, max int, precision int, unsigned bool) float64

指定区间随机生成

func RandFromArray

func RandFromArray(array *[]any) any

在数组中随机取一个

func RandFromArrayString

func RandFromArrayString(array []string) string

func RandNumber

func RandNumber(min, max float64, precision int) (float64, error)

指定区间随机生成

func RandNumberByLen

func RandNumberByLen(size int) string

生成随机字符串

func RandStringByLen

func RandStringByLen(size int) string

生成随机字符串

func RoundFloat

func RoundFloat(num float64, precision int) (float64, error)

Float 精度格式化

func SnakeCase

func SnakeCase(s string, allMode bool) string

*

  • 驼峰转蛇形 snake string
  • @description XxYy to xx_yy , XxYY to xx_y_y
  • @date 2023/10/13
  • @param s 需要转换的字符串
  • @param allMode true XxYY to xx_y_y false XxYY to xx_yy
  • @return string *

func StrToInterfaceArray

func StrToInterfaceArray(stringSlice []string) []any

string数组转接口数组

func String2Int

func String2Int(strArr []string) []int

string 数组转int数组

func Struct2map

func Struct2map(obj any) (data map[string]any, err error)

结构体转map

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