mirror of
https://github.com/usual2970/certimate.git
synced 2025-08-17 06:41:45 +00:00
.github
.vscode
docker
internal
applicant
certificate
deployer
domain
domains
notify
pkg
repository
rest
routes
scheduler
statistics
utils
app
http
rand
rand.go
resp
variables
xtime
workflow
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)
|
|
}
|