summary refs log tree commit diff stats
path: root/pkg
diff options
context:
space:
mode:
authorAndinus <andinus@inventati.org>2020-03-16 02:24:57 +0530
committerAndinus <andinus@inventati.org>2020-03-16 02:24:57 +0530
commitb5887c34637d87d41e07058f64470469304ba9aa (patch)
tree85b3c2997e0af171620af6a432a7b5248da26b17 /pkg
parentc6cd3372c23bac2d2662ebf55daa9dd35ddd5363 (diff)
downloadcetus-b5887c34637d87d41e07058f64470469304ba9aa.tar.gz
Add RandAlNum function
Diffstat (limited to 'pkg')
-rw-r--r--pkg/cetus/random.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/pkg/cetus/random.go b/pkg/cetus/random.go
new file mode 100644
index 0000000..d77a24b
--- /dev/null
+++ b/pkg/cetus/random.go
@@ -0,0 +1,16 @@
+package cetus
+
+import (
+	"math/rand"
+)
+
+// RandAlNum returns random alpha-numeric string of specific length
+func RandAlNum(n int) string {
+	rand.Seed(time.Now().UnixNano())
+	const alphanum = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
+	b := make([]byte, n)
+	for i := range b {
+		b[i] = letterBytes[rand.Intn(len(letterBytes))]
+	}
+	return string(b)
+}