Documentation
¶
Index ¶
- type TRandomArray
- type TRandomBoolean
- type TRandomDateTime
- type TRandomDouble
- type TRandomFloat
- type TRandomInteger
- type TRandomString
- type TRandomText
- func (c *TRandomText) Adjective() string
- func (c *TRandomText) Color() string
- func (c *TRandomText) Email() string
- func (c *TRandomText) FullName() string
- func (c *TRandomText) Noun() string
- func (c *TRandomText) Phone() string
- func (c *TRandomText) Phrase(minLength int, maxLength int) string
- func (c *TRandomText) Text(minLength int, maxLength int) string
- func (c *TRandomText) Verb() string
- func (c *TRandomText) Word() string
- func (c *TRandomText) Words(min int, max int) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TRandomArray ¶
type TRandomArray struct { }
var RandomArray TRandomArray = TRandomArray{}
Random generator for array objects. Example:
value1 := RandomArray.Pick([1, 2, 3, 4]); // Possible result: 3
func (*TRandomArray) Pick ¶
func (c *TRandomArray) Pick(values []interface{}) interface{}
type TRandomBoolean ¶
type TRandomBoolean struct { }
var RandomBoolean TRandomBoolean = TRandomBoolean{}
Random generator for boolean values.
Example:
value1 := RandomBoolean.NextBoolean(); // Possible result: true value2 := RandomBoolean.Chance(1,3); // Possible result: false
func (*TRandomBoolean) Chance ¶
func (c *TRandomBoolean) Chance(chance int, maxChances int) bool
Chance method are calculates "chance" out of "max chances". Example: 1 chance out of 3 chances (or 33.3%) - chance a chance proportional to maxChances. - maxChances a maximum number of chances
func (*TRandomBoolean) NextBoolean ¶
func (c *TRandomBoolean) NextBoolean() bool
Generates a random boolean value. Retruns: a random boolean.
type TRandomDateTime ¶
type TRandomDateTime struct { }
var RandomDateTime TRandomDateTime = TRandomDateTime{}
Random generator for Date time values.
Example:
value1 = RandomDateTime.NextDate(time.Date(2010,0,1)); // Possible result: 2008-01-03 value2 = RandomDateTime.NextDateTime(time.Date(2017,0.1)); // Possible result: 2007-03-11 11:20:32 value3 = RandomDateTime.UpdateDateTime(time.Date(2010,1,2)); // Possible result: 2010-02-05 11:33:23
func (*TRandomDateTime) NextDate ¶
Generates a random Date in the range ['minYear', 'maxYear']. This method generate dates without time (or time set to 00:00:00) Parameters: - min (optional) minimum range value - max max range value Returns: a random Date value.
func (*TRandomDateTime) NextDateTime ¶
Generates a random Date and time in the range ['minYear', 'maxYear']. This method generate dates without time (or time set to 00:00:00) Parameters: - min (optional) minimum range value - max max range value Returns: a random Date and time value.
func (*TRandomDateTime) UpdateDateTime ¶
Updates (drifts) a Date value within specified range defined - value a Date value to drift. - range (optional) a range in milliseconds. Default: 10 days
type TRandomDouble ¶
type TRandomDouble struct { }
var RandomDouble TRandomDouble = TRandomDouble{}
Random generator for double values.
Example:
value1 = RandomDouble.NextDouble(5, 10); // Possible result: 7.3 value2 = RandomDouble.NextDouble(0, 10); // Possible result: 3.7 value3 = RandomDouble.UpdateDouble(10, 3); // Possible result: 9.2
func (*TRandomDouble) NextDouble ¶
func (c *TRandomDouble) NextDouble(min float64, max float64) float64
NextDouble are generates a random double value in the range ['minYear', 'maxYear']. Paramaters: - min (optional) minimum range value - max max range value Returns: a random double value.
func (*TRandomDouble) UpdateDouble ¶
func (c *TRandomDouble) UpdateDouble(value float64, rng float64) float64
UpdateDouble method are updates (drifts) a double value within specified range defined Parameters: - value a double value to drift. - range (optional) a range. Default: 10% of the value Returns: a random double value.
type TRandomFloat ¶
type TRandomFloat struct{}
var RandomFloat TRandomFloat = TRandomFloat{}
Random generator for float values.
Example:
value1 = RandomFloat.NextFloat(5, 10); // Possible result: 7.3 value2 = RandomFloat.NextFloat(0, 10); // Possible result: 3.7 value3 = RandomFloat.UpdateFloat(10, 3); // Possible result: 9.2
func (*TRandomFloat) NextFloat ¶
func (c *TRandomFloat) NextFloat(min float32, max float32) float32
Generates a float in the range ['min', 'max']. If 'max' is omitted, then the range will be set to [0, 'min']. Parameters:
- min minimum value of the float that will be generated. If 'max' is omitted, then 'max' is set to 'min' and 'min' is set to 0.
- max (optional) maximum value of the float that will be generated. Defaults to 'min' if omitted.
Returns: generated random float value.
func (*TRandomFloat) UpdateFloat ¶
func (c *TRandomFloat) UpdateFloat(value float32, rng float32) float32
- value a float value to drift. - range (optional) a range. Default: 10% of the value
type TRandomInteger ¶
type TRandomInteger struct { }
var RandomInteger TRandomInteger = TRandomInteger{}
Random generator for integer values.
Example:
value1 = RandomInteger.NextInteger(5, 10); // Possible result: 7 value2 = RandomInteger.NextInteger(10); // Possible result: 3 value3 = RandomInteger.UpdateInteger(10, 3); // Possible result: 9
func (*TRandomInteger) NextInteger ¶
func (c *TRandomInteger) NextInteger(min int64, max int64) int64
Generates a integer in the range ['min', 'max']. If 'max' is omitted, then the range will be set to [0, 'min']. Parameters:
- min minimum value of the integer that will be generated. If 'max' is omitted, then 'max' is set to 'min' and 'min' is set to 0.
- max (optional) maximum value of the float that will be generated. Defaults to 'min' if omitted.
Returns generated random integer value.
func (*TRandomInteger) Sequence ¶
func (c *TRandomInteger) Sequence(min int64, max int64) []int64
Generates a random sequence of integers starting from 0 like: [0,1,2,3...??] Parameters:
- min minimum value of the integer that will be generated. If 'max' is omitted, then 'max' is set to 'min' and 'min' is set to 0.
- max (optional) maximum value of the float that will be generated. Defaults to 'min' if omitted.
Returns: generated array of integers.
func (*TRandomInteger) UpdateInteger ¶
func (c *TRandomInteger) UpdateInteger(value int64, rng int64) int64
Updates (drifts) a integer value within specified range defined Parameters: - value a integer value to drift. - range (optional) a range. Default: 10% of the value
type TRandomString ¶
type TRandomString struct {
// contains filtered or unexported fields
}
var RandomString TRandomString = NewTRandomString()
Random generator for string values. Example:
value1 = RandomString.PickChar("ABC"); // Possible result: "C" value2 = RandomString.Pick(["A","B","C"]); // Possible result: "gBW"
func NewTRandomString ¶
func NewTRandomString() TRandomString
func (*TRandomString) Distort ¶
func (c *TRandomString) Distort(value string) string
Distorts a string by randomly replacing characters in it. Parameters: - value a string to distort. Returns a distored string.
func (*TRandomString) NextAlphaChar ¶
func (c *TRandomString) NextAlphaChar() string
Generates random alpha characted [A-Za-z] Returns a random characted.
func (*TRandomString) NextString ¶
func (c *TRandomString) NextString(minLength int, maxLength int) string
Generates a random string, consisting of upper and lower case letters (of the English alphabet), digits (0-9), and symbols ("_,.:-/.[].{},#-!,$=%.+^.&*-() "). Parameters: - minLength (optional) minimum string length. - maxLength maximum string length. Returns a random string.
func (*TRandomString) Pick ¶
func (c *TRandomString) Pick(values []string) string
Picks a random string from an array of string. Parameters:
- values strings to pick from.
Returns a randomly picked string.
func (*TRandomString) PickChar ¶
func (c *TRandomString) PickChar(values string) string
Picks a random character from a string. Parameters:
- values a string to pick a char from
Returns a randomly picked char.
type TRandomText ¶
type TRandomText struct {
// contains filtered or unexported fields
}
var RandomText TRandomText = NewTRandomText()
Random generator for various text values like names, addresses or phone numbers.
Example:
value1 = c.Name(); // Possible result: "Segio" value2 = c.Verb(); // Possible result: "Run" value3 = c.Text(50); // Possible result: "Run jorge. Red high scream?"
func NewTRandomText ¶
func NewTRandomText() TRandomText
func (*TRandomText) Adjective ¶
func (c *TRandomText) Adjective() string
Generates a random adjective. The result value is capitalized. Returns: a random adjective.
func (*TRandomText) Color ¶
func (c *TRandomText) Color() string
Generates a random color name. The result value is capitalized. Returns: a random color name.
func (*TRandomText) Email ¶
func (c *TRandomText) Email() string
Generates a random email address. Returns: a random email address.
func (*TRandomText) FullName ¶
func (c *TRandomText) FullName() string
Generates a random person"s name which has the following structure <optional prefix> <first name> <second name> <optional suffix> Returns: a random name.
func (*TRandomText) Noun ¶
func (c *TRandomText) Noun() string
Generates a random noun. The result value is capitalized. Returns: a random noun.
func (*TRandomText) Phone ¶
func (c *TRandomText) Phone() string
Generates a random phone number. The phone number has the format: (XXX) XXX-YYYY Returns: a random phone number.
func (*TRandomText) Phrase ¶
func (c *TRandomText) Phrase(minLength int, maxLength int) string
Generates a random phrase which consists of few words separated by spaces. The first word is capitalized, others are not.
- minLength (optional) minimum string length.
- maxLength maximum string length.
Returns: a random phrase.
func (*TRandomText) Text ¶
func (c *TRandomText) Text(minLength int, maxLength int) string
Generates a random text, consisting of first names, last names, colors, stuffs, adjectives, verbs, and punctuation marks. - minLength minimum amount of words to generate. Text will contain "minSize" words if "maxSize" is omitted. - maxLength (optional) maximum amount of words to generate. Returns: a random text.
func (*TRandomText) Verb ¶
func (c *TRandomText) Verb() string
Generates a random verb. The result value is capitalized. Returns: a random verb.
func (*TRandomText) Word ¶
func (c *TRandomText) Word() string
Generates a random word from available first names, last names, colors, stuffs, adjectives, or verbs. Returns: a random word.