mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-12-25 00:56:35 +08:00
feat: 数据库支持选中数据生成insert语句
This commit is contained in:
25
server/pkg/utils/rand.go
Normal file
25
server/pkg/utils/rand.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"time"
|
||||
)
|
||||
|
||||
const randChar = "0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
|
||||
// 生成随机字符串
|
||||
func RandString(l int) string {
|
||||
strList := []byte(randChar)
|
||||
|
||||
result := []byte{}
|
||||
i := 0
|
||||
|
||||
r := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
charLen := len(strList)
|
||||
for i < l {
|
||||
new := strList[r.Intn(charLen)]
|
||||
result = append(result, new)
|
||||
i = i + 1
|
||||
}
|
||||
return string(result)
|
||||
}
|
||||
Reference in New Issue
Block a user