Popularity
0.4
Stable
Activity
0.0
Stable
4
1
0

Description

A safe time-independent random number/string generator.

Programming language: Go
License: Apache License 2.0
Tags: Utilities     Tools     Strings     Random Generator     Random    
Latest version: v1.0.2

RanGo alternatives and similar packages

Based on the "Utilities" category.
Alternatively, view RanGo alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of RanGo or a related project?

Add another 'Utilities' Package

README

[RanGo Logo](#)

🦎RanGo PkgGoDev Go Report Card [Go version](#) [Go coverage](#) [GitHub license](#)

A time-independent random number/string generator.

📦Installation

First:

go get github.com/yektadev/rango

Then, add the dependency to your code:

import "github.com/yektadev/rango"

📝Simple Usage

Here's all you need to do in order to:

🔺Generate a random int:

Use:

RanGo.RnInt(startIncluded int, endNotIncluded int)

Example:

r := RanGo.RnInt(0,8)  //r ϵ {0,1,2,...,6,7}

🔺Generate a random string from a set of characters:

Use:

RanGo.RnStringFrom(length int, chars string)

Example:

r := RanGo.RnStringFrom(8,"abcd")  //r (example): "dadaadbb"

🔺Generate a random string:

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"

🔧More Options

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 of RnInt().
  • RandomStringFrom() instead of RnStringFrom().
  • RandomString() instead of RnString().

In case of using these functions, you'll have isSeedTimeDependent boolean as the second returned output.


Special thanks to John Leidegren because of this answer on Stack Overflow.

[](#)


*Note that all licence references and agreements mentioned in the RanGo README section above are relevant to that project's source code only.