36 lines
655 B
Go
36 lines
655 B
Go
package util
|
|
|
|
import (
|
|
"math/rand"
|
|
)
|
|
|
|
// RandStringRunes 返回随机字符串
|
|
func RandStringRunes(n int) string {
|
|
var letterRunes = []rune("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
|
|
|
b := make([]rune, n)
|
|
for i := range b {
|
|
b[i] = letterRunes[rand.Intn(len(letterRunes))]
|
|
}
|
|
return string(b)
|
|
}
|
|
|
|
// ContainsUint 返回list中是否包含
|
|
func ContainsUint(s []uint, e uint) bool {
|
|
for _, a := range s {
|
|
if a == e {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
// ContainsString 返回list中是否包含
|
|
func ContainsString(s []string, e string) bool {
|
|
for _, a := range s {
|
|
if a == e {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|