utils

package
v0.0.0-...-b81b3d3 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AESDecrypt

func AESDecrypt(data []byte, key []byte) ([]byte, error)

func AESEncrypt

func AESEncrypt(data []byte, key []byte) ([]byte, error)

func ComparePasswords

func ComparePasswords(hashedPassword, inputPassword string) (bool, error)

ComparePasswords 使用bcrypt库的CompareHashAndPassword函数比较密码

func CountSubString

func CountSubString(s string, separator string) int

func DaysInMonth

func DaysInMonth(year, month int) int

func DecryptByAES

func DecryptByAES(data, key string) (string, error)

DecryptByAES 解密

func ElementExist

func ElementExist(value interface{}, sli interface{}) bool

ElementExist 切片是否包含某个元素

func EncryptByAES

func EncryptByAES(data, key string) (string, error)

EncryptByAES 使用AES加密data, key的长度只支持16、32、64 Byte

func HashPassword

func HashPassword(password string) (string, error)

HashPassword 使用bcrypt库的GenerateFromPassword函数进行哈希处理

func HttpDo

func HttpDo(method, url string, headers, query map[string]string, b string) (*http.Response, []byte, error)

func HumanFormatTimeSeconds

func HumanFormatTimeSeconds(seconds int) string

HumanFormatTimeSeconds 将秒转换为便于人阅读的格式

func Intersect

func Intersect(o, n []string) []string

Intersect 2个切片的交集

func IsMail

func IsMail(mail string) bool

func IsSliceEqual

func IsSliceEqual(a, b interface{}) bool

IsSliceEqual 2个切片是否相等(忽略元素顺序)

func IsSubSlices

func IsSubSlices(sub []string, sli []string) bool

IsSubSlices sub是否是sli子切片

func IsTimeInRange

func IsTimeInRange(t time.Time, startTime, endTime string) (bool, error)

IsTimeInRange 时间是否在某个区间内

func NonIntersect

func NonIntersect(o, n []string) []string

func ParseAddr

func ParseAddr(addr, defHost string, defPort int) (string, int, error)

func RandStr

func RandStr(length int) string

func RemoveDupElement

func RemoveDupElement[T comparable](sli []T) []T

RemoveDupElement 切片元素去重(字符串)

func RemoveSubSlices

func RemoveSubSlices(sli []string, del []string) []string

RemoveSubSlices 删除子切片元素

func SliceToString

func SliceToString[T any](sli []T, separator string) string

func Ternary

func Ternary[T any](b bool, v1, v2 any) T

Ternary 模拟三目运算

func TrimmingSQLConditionEnding

func TrimmingSQLConditionEnding(condition string) string

TrimmingSQLConditionEnding 修剪where条件后多余的空格和";"

func TrimmingStringList

func TrimmingStringList(org, split string) string

TrimmingStringList 修剪字符串去除多余的空格字符(会去除重复项!!!)

Types

This section is empty.

Jump to

Keyboard shortcuts

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