summaryrefslogtreecommitdiff
path: root/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'helpers')
-rw-r--r--helpers/helpers.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/helpers/helpers.go b/helpers/helpers.go
index ac92e6a..1db691b 100644
--- a/helpers/helpers.go
+++ b/helpers/helpers.go
@@ -3,9 +3,13 @@ package helpers
import (
"fmt"
"strings"
+ "math/rand"
+ "time"
"strconv"
)
+var r = rand.New(rand.NewSource(time.Now().UnixNano()))
+
func Ask(str string) bool {
var input string
fmt.Printf("-> %s (Y/n): ", str)
@@ -30,3 +34,11 @@ func ToString(v interface{}) string {
return ""
}
}
+
+func RandStr(n int) string {
+ b := make([]byte, n)
+ for i := range b {
+ b[i] = byte(r.Intn(26) + 'a')
+ }
+ return string(b)
+}