Basic
Bool
Bool
returns a random bool value. By default, values have equal probability.
Parameters
WithLikelihood
WithLikelihood
parameter allows to set the likelihood of the True
result.
It accepts v
, float64 value in the range [0, 1].
Integer
Integer
returns a random integer value.
By default, the range is from -262 to 262-1.
flk.Integer() // 3203168211198807973
// above is same as
flk.Integer(f.WithIntRange(math.MinInt64, math.MaxInt64))
Parameters
WithIntRange
WithIntRange
parameter allows to set the range of the result.
It accepts min
and max
values, int
.
The min
and max
values included in the range.
Float
Float
returns a random float64 value.
By default, the range is from 0 to 1 and precision not limited (-1
).
The max value not included in the range.
flk.Float() // 0.5322073040624193
// above is same as
flk.Float(f.WithFloatRange(0, 1), f.WithPrecision(-1))
Parameters
WithFloatRange
WithFloatRange
parameter allows to set the range of the result.
It accepts min
and max
values, float64
.
The max
value not included in the range.
WithPrecision
WithPrecision
parameter allows to set the precision of the result.
It accepts p
, int8
value.
The p
value is the number of digits after the decimal point.
The negative value does not change the result.
Max value is 20.
flk.Float(f.WithPrecision(0)) // 1
flk.Float(f.WithPrecision(2)) // 0.53
flk.Float(f.WithPrecision(-1)) // 0.5322073040624193
String
String
returns a random string value.
By default, the length is between 5 and 20 and
the charset is:
- latin lower (
abcdefghijklmnopqrstuvwxyz
) - latin upper (
ABCDEFGHIJKLMNOPQRSTUVWXYZ
) - numbers (
0123456789
) - symbols (
!@#$%^&*+=_-
).
flk.String() // peSnT7UeH0fq4sm
// above is same as
flk.String(f.WithLengthRange(5, 20), f.WithLatinLowerAlphabet(), f.AndLatinUpperAlphabet(), f.AndNumericAlphabet(), AndSymbolsAlphabet())
Parameters
WithLength
WithLength
parameter allows to set the length of the result.
It accepts l
, uint8
value.
WithLengthRange
WithLengthRange
parameter allows to set the length range of the result.
It accepts min
and max
values, uint8
. The min
and max
values included in the range.
WithAlphabet
WithAlphabet
parameter allows to set the charset of the result.
It accepts alphabet
, string
value.
AndAlphabet
AndAlphabet
parameter allows to extend the charset of the result by the given alphabet.
WithNumericAlphabet
WithNumericAlphabet
parameter allows to set the charset of the result to numbers.
AndNumericAlphabet
AndNumericAlphabet
parameter allows to extend the charset of the result by numbers.
WithLatinLowerAlphabet
WithLatinLowerAlphabet
parameter allows to set the charset of the result to lower case letters.
AndLowerAlphabet
AndLatinLowerAlphabet
parameter allows to extend the charset of the result by lower case letters.
WithLatinUpperAlphabet
WithLatinUpperAlphabet
parameter allows to set the charset of the result to upper case letters.
AndLatinUpperAlphabet
AndLatinUpperAlphabet
parameter allows to extend the charset of the result by upper case letters.
WithSymbolsAlphabet
WithSymbolsAlphabet
parameter allows to set the charset of the result to symbols.
The symbols are: !@#$%^&*+=_-
.
AndSymbolsAlphabet
AndSymbolsAlphabet
parameter allows to extend the charset of the result by symbols.
The symbols are: !@#$%^&*+=_-
.
WithSymbolsUrlSafeAlphabet
WithSymbolsUrlSafeAlphabet
parameter allows to set the charset of the result to url safe symbols.
The symbols are: _-
.
AndSymbolsUrlSafeAlphabet
AndSymbolsUrlSafeAlphabet
parameter allows to extend the charset of the result by url safe symbols.
The symbols are: _-
.
WithUrlSafeAlphabet
WithUrlSafeAlphabet
parameter allows to set the charset of the result to url safe symbols and letters.
The symbols are: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-
.
WithHexAlphabet
WithHexAlphabet
parameter allows to set the charset of the result to hex symbols.
The symbols are: 0123456789abcdef
.
WithUkrainianLowerAlphabet
WithUkrainianLowerAlphabet
parameter allows to set the charset of the result to ukrainian lower case letters.
AndUkrainianLowerAlphabet
AndUkrainianLowerAlphabet
parameter allows to extend the charset of the result by ukrainian lower case letters.
WithUkrainianUpperAlphabet
WithUkrainianUpperAlphabet
parameter allows to set the charset of the result to ukrainian upper case letters.
AndUkrainianUpperAlphabet
AndUkrainianUpperAlphabet
parameter allows to extend the charset of the result by ukrainian upper case letters.
WithGreekLowerAlphabet
WithGreekLowerAlphabet
parameter allows to set the charset of the result to greek lower case letters.
AndGreekLowerAlphabet
AndGreekLowerAlphabet
parameter allows to extend the charset of the result by greek lower case letters.
WithGreekUpperAlphabet
WithGreekUpperAlphabet
parameter allows to set the charset of the result to greek upper case letters.
AndGreekUpperAlphabet
AndGreekUpperAlphabet
parameter allows to extend the charset of the result by greek upper case letters.