From f3eb85dd954b4240520f199a77958da0939fa229 Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Fri, 21 Sep 2018 22:26:10 -0700 Subject: [PATCH] add randome name --- src/utils/randomname.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/utils/randomname.go diff --git a/src/utils/randomname.go b/src/utils/randomname.go new file mode 100644 index 0000000..b044e09 --- /dev/null +++ b/src/utils/randomname.go @@ -0,0 +1,16 @@ +package utils + +import ( + "crypto/rand" + "strings" + + "github.com/schollz/mnemonicode" +) + +func GetRandomName() string { + result := []string{} + bs := make([]byte, 4) + rand.Read(bs) + result = mnemonicode.EncodeWordList(result, bs) + return strings.Join(result, "-") +}