utils

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeUnknown = iota
	TypeEmail
	TypeMobile
	TypeId
	TypeName
)
View Source
const (
	CacheAuthToken = "auth_token_user_%s"
)

Variables

View Source
var (
	EmailRegex  = regexp.MustCompile(`^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$`)
	MobileRegex = regexp.MustCompile(`^1[345789]\d{9}$`)
	DigitRegex  = regexp.MustCompile(`^\d{1,20}$`)
	LetterRegex = regexp.MustCompile(`^[a-zA-Z]\w+$`)
	MD5Regex    = regexp.MustCompile(`^[0-9a-fA-F]{32}$`)
)
View Source
var DBC2SBC = unicode.SpecialCase{
	unicode.CaseRange{
		Lo: 0x3002,
		Hi: 0x3002,
		Delta: [unicode.MaxCase]rune{
			0,
			0x002e - 0x3002,
			0,
		},
	},

	unicode.CaseRange{
		Lo: 0xFF01,
		Hi: 0xFF19,
		Delta: [unicode.MaxCase]rune{
			0,
			0x0021 - 0xFF01,
			0,
		},
	},
}
View Source
var (
	ImageFormat = []string{".jpg", ".jpeg", ".png", ".bmp", ".gif"}
)

Functions

func Base58Decode added in v0.5.5

func Base58Decode(input []byte) []byte

Base58Decode 解码

func Base58Encode added in v0.5.5

func Base58Encode(input []byte) []byte

Base58Encode 编码

func CutRune

func CutRune(str string, n int) string

func RandByte added in v0.5.5

func RandByte(length int) []byte

RandByte 获取指定长度的随机byte

func RandHumanStr added in v0.5.5

func RandHumanStr(length int) string

RandHumanStr 获取便于人类识别的随机字符串(避开了易混淆的字符1l0O等)

func RandStr

func RandStr(n int) string

func ReverseBytes added in v0.5.5

func ReverseBytes(data []byte)

ReverseBytes 翻转字节

func UsernameType added in v0.5.1

func UsernameType(username string) int

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