util/util.go   A
last analyzed

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 12
dl 0
loc 20
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A util.init 0 2 1
A util.RandString 0 6 2
1
////////////////////////////////////////////////////////////////////////////////
2
// Author:   Nikita Koryabkin
3
// Email:    [email protected]
4
// Telegram: https://t.me/Apologiz
5
////////////////////////////////////////////////////////////////////////////////
6
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