随机字符串
(size int, kind int)
| 14 | |
| 15 | // 随机字符串 |
| 16 | func Krand(size int, kind int) []byte { |
| 17 | ikind, kinds, result := kind, [][]int{[]int{10, 48}, []int{26, 97}, []int{26, 65}}, make([]byte, size) |
| 18 | isAll := kind > KC_RAND_KIND_UPPER || kind < KC_RAND_KIND_NUM |
| 19 | rand.Seed(time.Now().UnixNano()) |
| 20 | for i := 0; i < size; i++ { |
| 21 | if isAll { // random ikind |
| 22 | ikind = rand.Intn(3) |
| 23 | } |
| 24 | scope, base := kinds[ikind][0], kinds[ikind][1] |
| 25 | result[i] = uint8(base + rand.Intn(scope)) |
| 26 | } |
| 27 | |
| 28 | return result |
| 29 | } |
no outgoing calls
no test coverage detected