A time-independent random number/string generator.
First:
go get github.com/yektadev/rango
Then, add the dependency to your code:
import "github.com/yektadev/rango"Here's all you need to do in order to:
Use:
RanGo.RnInt(startIncluded int, endNotIncluded int)Example:
r := RanGo.RnInt(0,8) //r ϵ {0,1,2,...,6,7}Use:
RanGo.RnStringFrom(length int, chars string)Example:
r := RanGo.RnStringFrom(8,"abcd") //r (example): "dadaadbb"Use:
RanGo.RnString(length int, containsLowercase bool, containsUppercase bool, containsNumber bool, containsSpecial bool)Examples:
r := RanGo.RnString(18,true,true,true,true) //r (example): "}WCg*(?w4P$<HS\jOb"r := RanGo.RnString(18,true,false,false,false) //r (example): "jzoqagpchhsyhotvrj"r := RanGo.RnString(18,false,false,true,false) //r (example): "325803510203358683"If the above functions face an error while generating a time-independent seed, the seed will be automatically generated using time.Now().UnixNano(). If you need to know whether the seed is generated time-dependent or time-independent, then use the following functions:
RandomInt()instead ofRnInt().RandomStringFrom()instead ofRnStringFrom().RandomString()instead ofRnString().
In case of using these functions, you'll have isSeedTimeDependent boolean as the second returned output.
