RandomStr 随机生成字符串
(length int)
| 7 | |
| 8 | // RandomStr 随机生成字符串 |
| 9 | func RandomStr(length int) string { |
| 10 | str := "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" |
| 11 | bytes := []byte(str) |
| 12 | result := []byte{} |
| 13 | r := rand.New(rand.NewSource(time.Now().UnixNano())) |
| 14 | for i := 0; i < length; i++ { |
| 15 | result = append(result, bytes[r.Intn(len(bytes))]) |
| 16 | } |
| 17 | return string(result) |
| 18 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…