mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
add randome name
This commit is contained in:
parent
ebac8beaaa
commit
f3eb85dd95
1 changed files with 16 additions and 0 deletions
16
src/utils/randomname.go
Normal file
16
src/utils/randomname.go
Normal file
|
@ -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, "-")
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue