MCPcopy
hub / github.com/eolinker/goku_lite / GetRandomString

Function GetRandomString

utils/function.go:87–96  ·  view source on GitHub ↗

GetRandomString 生成随机字符串

(num int)

Source from the content-addressed store, hash-verified

85
86//GetRandomString 生成随机字符串
87func GetRandomString(num int) string {
88 str := "123456789abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ"
89 bytes := []byte(str)
90 result := []byte{}
91 r := rand.New(rand.NewSource(time.Now().UnixNano()))
92 for i := 0; i < num; i++ {
93 result = append(result, bytes[r.Intn(len(bytes))])
94 }
95 return string(result)
96}
97
98//CheckFileIsExist 判断文件是否存在 存在返回 true 不存在返回false
99func CheckFileIsExist(filename string) bool {

Callers 2

AddNodeFunction · 0.92
AddStrategyMethod · 0.92

Calls 2

appendFunction · 0.85
NewMethod · 0.65

Tested by

no test coverage detected