util

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Capitalize

func Capitalize(str string) string

Capitalize 字符首字母大写转换

Types

type Array

type Array[T comparable] struct{}

func (Array[T]) Exist

func (a Array[T]) Exist(array []T, val T) (index int)

Exist 数组中是否存在某值,返回下标

func (Array[T]) Unique

func (a Array[T]) Unique(array ...T) []T

Unique 数组去重

type Bind

type Bind struct {
	IgnoreEmpty bool // 是否忽视空值
	DeepCopy    bool // 是否深度拷贝
}

func (Bind) Copy

func (b Bind) Copy(dst, src any) (err error)

Copy 将源数据src值赋值给目标数据dst src->dst

func (Bind) CopyJson

func (b Bind) CopyJson(dst, src any) error

CopyJson 将源数据src值赋值给目标数据dst src->dst 通过json的方式赋值

type Convert

type Convert struct{}

func (Convert) StructToMap

func (c Convert) StructToMap(obj any) map[string]any

StructToMap 结构体转map

type Crypto

type Crypto struct {
	AesKey16 string // 加解密的密钥(长度为16位)
}

func (*Crypto) Check

func (c *Crypto) Check(pwd, hash string) bool

Check hash校验

func (*Crypto) Decrypt

func (c *Crypto) Decrypt(encrypt string) (string, error)

Decrypt aes解密

func (*Crypto) Encrypt

func (c *Crypto) Encrypt(str string) (string, error)

Encrypt aes加密

func (*Crypto) Hash

func (c *Crypto) Hash(pwd string) (string, error)

Hash hash加密

type PinYin

type PinYin struct{}

func (PinYin) PinYin

func (p PinYin) PinYin(str string) (retStr string)

PinYin 中文汉字全拼,且拼音首字母大写

func (PinYin) PinYinFirst

func (p PinYin) PinYinFirst(str string) (retStr string)

PinYinFirst 中文汉字拼音首字母小写

type Regex

type Regex struct{}

func (Regex) Camel2Case

func (t Regex) Camel2Case(s string) string

Camel2Case 驼峰转小写下划线 AbbCdd转换成abb_cdd

func (Regex) IsEmail

func (t Regex) IsEmail(s string) bool

IsEmail 判断邮箱

func (Regex) IsPhone

func (t Regex) IsPhone(s string) bool

IsPhone 判断手机号

func (Regex) Password

func (t Regex) Password(s string) bool

Password 密码长度8为以上数字和字母

type String

type String struct {
	// contains filtered or unexported fields
}

func NewString

func NewString(split string) String

func (String) JoinByStruct

func (s String) JoinByStruct(obj any) (str string, err error)

JoinByStruct 对象转成字符串

type SyncChan

type SyncChan struct {
	// contains filtered or unexported fields
}

func NewSyncChanUtil

func NewSyncChanUtil(count int32) *SyncChan

NewSyncChanUtil 多线程控制,限制线程数量

func (SyncChan) Add

func (s SyncChan) Add()

Add 实现多线程运行,且限制线程数量为num

func (SyncChan) Done

func (s SyncChan) Done()

Done 线程运行结束是需要执行结束

func (SyncChan) Wait

func (s SyncChan) Wait()

Wait 等待线程执行

type Time

type Time struct {
	Format string
}

func (Time) NowTime

func (t Time) NowTime() string

NowTime 当前时间

func (Time) NowZero

func (t Time) NowZero() string

NowZero 当天凌晨

func (Time) ParseInLocation

func (t Time) ParseInLocation(s string) (time.Time, error)

ParseInLocation 字符串转换成时间

func (Time) StringToTime

func (t Time) StringToTime(s string) (rt time.Time, err error)

StringToTime 字符串转换成时间

func (Time) ToString

func (t Time) ToString(ti time.Time) string

ToString 时间返回字符串

func (Time) Tomorrow

func (t Time) Tomorrow() string

Tomorrow 明天

func (Time) TomorrowZero

func (t Time) TomorrowZero() time.Time

TomorrowZero 明天凌晨

func (Time) TomorrowZeroString

func (t Time) TomorrowZeroString() string

TomorrowZeroString 明天凌晨

Jump to

Keyboard shortcuts

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