mirror of
https://github.com/usual2970/certimate.git
synced 2025-07-19 09:29:52 +00:00
.github
.vscode
docker
internal
applicant
deployer
domain
domains
notify
pkg
repository
rest
routes
utils
app
http
rand
rand.go
resp
variables
xtime
migrations
ui
.dockerignore
.editorconfig
.gitignore
.goreleaser.yml
CHANGELOG.md
CONTRIBUTING.md
CONTRIBUTING_EN.md
Dockerfile
LICENSE.md
Makefile
README.md
README_EN.md
go.mod
go.sum
main.go
nixpacks.toml
usage.gif
25 lines
519 B
Go
25 lines
519 B
Go
package rand
|
|
|
|
import (
|
|
"math/rand"
|
|
"time"
|
|
)
|
|
|
|
// Deprecated: this will be removed in the future.
|
|
// 随机生成指定长度字符串
|
|
func RandStr(n int) string {
|
|
seed := time.Now().UnixNano()
|
|
source := rand.NewSource(seed)
|
|
random := rand.New(source)
|
|
|
|
letters := []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
|
|
|
|
// 使用循环生成指定长度的字符串
|
|
result := make([]rune, n)
|
|
for i := range result {
|
|
result[i] = letters[random.Intn(len(letters))]
|
|
}
|
|
|
|
return string(result)
|
|
}
|