Skip to content

kayslay/random-str

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Package random-str

CircleCI

str "github.com/kayslay/random-str"

Package random-str generates random strings that follow a format.

Example usage:

s = str.WriteN(10, 'A') // s will be "NBHTFGREDC" (all caps)

Format

random-str can create random strings that conform to a particular format. The available formats are:

A: return only uppercase (ABC)

a: return only lowercase (abc)

d: return only digits (123)

s: return only symbols (&^%)

*: return any char (Aa1*)

check example

FUNCTIONS

func WriteFromFormat
func WriteFromFormat(format string) string

WriteFromFormat generates a string that follow the given format. format parameter is a string that says how the random string will be formated.

Example:

s1:= str.WriteFromFormat("Aads") // this returns a string with a capital letter,
// small letter, digit and a string in order"Gf3("
WriteN
func WriteN(n int, format ...rune) string

WriteN generates a string with length n. if format is specified, the string will be of the given format. only the first format passed will be used.

Example:

s1:= str.WriteN(10,"A") // returns random uppercase string of len 10 "ANBCHTEDFO"
s2:= str.WriteN(10,"a") // returns random lowercase string of len 10 "gahdbyeheb"
s3:= str.WriteN(10,) // returns random string of len 10 "Ay45)-hBN*"

About

return random string

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages