Total Lines | 20 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | //////////////////////////////////////////////////////////////////////////////// |
||
7 | package util |
||
8 | |||
9 | import ( |
||
10 | "math/rand" |
||
11 | "time" |
||
12 | ) |
||
13 | |||
14 | func init() { |
||
15 | rand.Seed(time.Now().UnixNano()) |
||
16 | } |
||
17 | |||
18 | var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") |
||
19 | |||
20 | //RandString returns random string |
||
21 | func RandString(n int) string { |
||
22 | b := make([]rune, n) |
||
23 | for i := range b { |
||
24 | b[i] = letterRunes[rand.Intn(len(letterRunes))] |
||
25 | } |
||
26 | return string(b) |
||
27 | } |
||
28 |