util

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2025 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AesEncrypt

func AesEncrypt(key []byte, text []byte) string

func BcryptCheck

func BcryptCheck(password, hash string) bool

BcryptCheck 对比明文密码和数据库的哈希值

func BcryptHash

func BcryptHash(password string) string

BcryptHash 使用 bcrypt 对密码进行加密

func CopyStruct

func CopyStruct(dst, src interface{})

CopyStruct ,浅复制! dst 目标结构体,src 源结构体 必须传入指针,且不能为nil 它会把src与dst的相同字段名的值,复制到dst中

func Decrypt

func Decrypt(key []byte, ciphertext []byte) ([]byte, error)

func Encrypt

func Encrypt(key []byte, text []byte) ([]byte, error)

func FileExists

func FileExists(filename string) (bool, error)

func GetDefaultHttpClient

func GetDefaultHttpClient() *req.Client

func GetDistance

func GetDistance(lat, lon float64, lat2, lon2 float64) float64

func GetFreePort

func GetFreePort() (int, error)

func GetRandInt64

func GetRandInt64() string

func GetUUID

func GetUUID() string

func GetUUIDStr

func GetUUIDStr() string

func IF

func IF[V any](predicate bool, then V, otherwise V) V

func If

func If[V any](predicate bool, then func() V, otherwise func() V) V

func InitDockerMysqlForTest

func InitDockerMysqlForTest() (string, string, error)

func IsEmptyArrayOrSlice

func IsEmptyArrayOrSlice(i interface{}) bool

func MD5V

func MD5V(str []byte, b ...byte) string

func Md5

func Md5(str string) string

func PKCS5Padding

func PKCS5Padding(ciphertext []byte, blockSize int) []byte

func PKCS5UnPadding

func PKCS5UnPadding(ciphertext []byte) []byte

func RandInt

func RandInt(min, max int) int

func ReGroup

func ReGroup[T1 any, T2 comparable](list []T1, fn func(a T1) T2) map[T2][]T1

func StopDockerMysqlForTest

func StopDockerMysqlForTest(containerName string) error

func ToAnyArray

func ToAnyArray[T any](list []T) []any

func ToJson

func ToJson(data interface{}) (string, error)

ToJson 对象转 json 字符串

func ToJsonWithoutErr

func ToJsonWithoutErr(data interface{}, defaultVal string) string

ToJsonWithoutErr 对象转 json 字符串,忽略异常

func UnmarshalJson

func UnmarshalJson(jsonStr string, data interface{}) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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