MCPcopy Create free account
hub / github.com/GoSimplicity/LinkMe / GenRandomCode

Function GenRandomCode

utils/sms.go:9–16  ·  view source on GitHub ↗

GenRandomCode 生成随机数

(length int)

Source from the content-addressed store, hash-verified

7
8// GenRandomCode 生成随机数
9func GenRandomCode(length int) string {
10 letters := []rune("123456789")
11 code := make([]rune, length)
12 for i := range code {
13 code[i] = letters[rand.Intn(len(letters))]
14 }
15 return string(code)
16}
17
18// IsValidNumber 检查给定的字符串是否符合中国的手机号格式
19func IsValidNumber(number string) bool {

Callers 3

TestQQEmailFunction · 0.92
SendCodeMethod · 0.92
SendCodeMethod · 0.92

Calls

no outgoing calls

Tested by 1

TestQQEmailFunction · 0.74