Initial commit

This commit is contained in:
2026-05-20 16:13:58 +08:00
commit ceffbe382e
500 changed files with 157469 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
package gencode
import (
"math/rand"
"time"
)
/**
* 生成邀请码
*/
var (
//所有的字符
ALL_CHARS = []string{
"1", "2", "3", "4", "5",
"6", "7", "8", "9", "A",
"B", "C", "D", "E", "F",
"G", "H", "J", "K",
"L", "M", "N", "O", "P",
"Q", "R", "S", "T", "U",
"V", "W", "X", "Y", "Z"}
aLen = len(ALL_CHARS)
)
const (
//默认长度
DEFAULT_LEN = 6
)
func init() {
rand.Seed(time.Now().Unix())
}
// 生成指定长度的码
func CodeGenerate(len int) (code string) {
for i := 0; i < len; i++ {
index := rand.Intn(aLen)
code += ALL_CHARS[index]
}
return
}