Skip to content

random string generator for golang

License

Notifications You must be signed in to change notification settings

0xNOY/go-randstr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-randstr

random string generator for golang

example

s := randstr.Gen(10)
fmt.Print(s) // output: mUNERA9rI2


// SrcLetters is source of random string generated.(Default: A~Z & a~z & 0~9)
randstr.SetSrcLetters([]rune("グレープフルーツ最高!!あとマンゴーも!!"))
s = randstr.Gen(6)
fmt.Print(s) // output: あ高ツフマレ

randstr.SetSrcLetters([]rune(randstr.LettersNumStr + randstr.LettersUpperStr))
s = randstr.Gen(8)
fmt.Print(s) // output: IIDAZG7H


// setting seed
randstr.GetRandModule().Seed(47)


// new RandStr
rs := randstr.New(
	rand.NewSource(2003),
	[]rune(randstr.LettersNumStr+"+-*/"),
)
s = rs.Gen(16)
fmt.Print(s) // output: 587466+2343008+8