Skip to content

sunjayaali/randstr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Randstr

A simple random string generator using crypto/rand package.

Install

go get -u github.com/xyluet/randstr

Example

s, err := randstr.String(32)
if err != nil {
  // check err
}
fmt.Println(s) // example output: cpjszbw8jrSFXp42

Example above will generate a random string default charset [A-z0-9].

s, err := randstr.StringWithCharset(16, "ABC")
if err != nil { panic(err) }
fmt.Println(s) // example output: BBAAACCCBBCBBCAA

References