utils

package
v0.0.0-...-5aa3412 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BcryptCompare

func BcryptCompare(passwordHash, plainPassword string) bool

func BcryptGetCost

func BcryptGetCost(passwordHash string) int

func BcryptPassword

func BcryptPassword(plainPassword string) (string, error)

func CopyStruct

func CopyStruct(src, dest interface{}) error

func GenerateSpanId

func GenerateSpanId(addr string) string

GenerateSpanId 生成spanId,思路:ip(空间唯一)与时间戳(时间唯一)异或运算+随机数

func GetTraceInfoFromCtx

func GetTraceInfoFromCtx(ctx context.Context) (traceId, spanId, pSpanId string)

GetTraceInfoFromCtx 从ctx中获取trace信息

func MaskEmail

func MaskEmail(address string) string

MaskEmail 隐藏邮箱ID的中间部分 zhang@go-mall.com ---> z***g@go-mall.com

func MaskLoginName

func MaskLoginName(loginName string) string

MaskLoginName 登录名做脱敏处理

func MaskPhone

func MaskPhone(phone string) string

MaskPhone 隐去手机号中间 4 位地区码, 如 155****8888

func MaskRealName

func MaskRealName(realName string) string

MaskRealName 保留姓名首末位 如:张三--->张* 赵丽颖--->赵*颖 欧阳娜娜--->欧**娜

func PasswordComplexityVerify

func PasswordComplexityVerify(s string) bool

func RandNumStr

func RandNumStr(len uint8) string

func RandomString

func RandomString(length uint8) string

func SetCharset

func SetCharset(c Charset)

Types

type Charset

type Charset string
const (
	Alphanumeric Charset = Alphabetic + Numeric
	Alphabetic   Charset = "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	Numeric      Charset = "0123456789"
	Hex          Charset = Numeric + "abcdef"
)

type Random

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

func NewRandom

func NewRandom() *Random

func (*Random) SetCharset

func (r *Random) SetCharset(c Charset)

func (*Random) String

func (r *Random) String(length uint8) string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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