random

package
v1.0.1-3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2022 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Array = &_TRandomArray{}

Array random generator for array objects.

Examples:
	value1 := random.Array.Pick([1, 2, 3, 4]); // Possible result: 3
View Source
var Boolean = &_TRandomBoolean{}

Boolean Random generator for boolean values.

Example:
	value1 := RandomBoolean.Next();      // Possible result: true
	value2 := RandomBoolean.Chance(1,3); // Possible result: false
View Source
var DateTime = &TRandomDateTime{}

DateTime random generator for Date time values.

Example:
	value1 := random.DateTime.nextDate(time.Parse(shortForm, "2007-Jan-01"), time.Parse(shortForm, "2010-Jan-01"));    // Possible result: 2008-01-03
	value2 := random.DateTime.nextDateTime(time.Parse(shortForm, "2006-Jan-01"), time.Parse(shortForm, "2017-Jan-01"));// Possible result: 2007-03-11 11:20:32
	value3 := random.DateTime.updateDateTime(time.Parse(shortForm, "2010-Jan-01"), );// Possible result: 2010-02-05 11:33:23
View Source
var Double = &_TRandomDouble{}

Double random generator for double values.

Example:
	value1 := random.Double.Next(5, 10);     // Possible result: 7.3
	value2 := random.Double.Update(10, 3);   // Possible result: 9.2
View Source
var Float = &_TRandomFloat{}

Float Random generator for float values.

Examples:
	value1 := random.Float.Next(5, 10);     // Possible result: 7.3
	value2 := random.Float.Update(10, 3);   // Possible result: 9.2
View Source
var Integer = &_TRandomInteger{}

Integer Random generator for integer values.

Example:
	value1 := random.Integer.Next(5, 10);     // Possible result: 7
	value2 := random.Integer.Update(10, 3);   // Possible result: 9
View Source
var Long = &_TRandomLong{}

Long random generator for integer values.

Example:
	value1 := random.Long.Next(5, 10);     // Possible result: 7
	value2 := random.Long.Update(10, 3);   // Possible result: 9
View Source
var String = &_TRandomString{}

String random generator for string values.

Example:
	value1 := random.String.PickChar("ABC");     // Possible result: "C"
	value2 := random.String.Pick(["A","B","C"]); // Possible result: "gBW"
View Source
var Text = &_TRandomText{}

Text random generator for various text values like names, addresses or phone numbers.

Example:
	value1 := RandomText.FullName();    // Possible result: "Segio"
	value2 := RandomText.Verb();      	// Possible result: "Run"
	value3 := RandomText.Text(50);    	// Possible result: "Run jorge. Red high scream?"

Functions

This section is empty.

Types

type TRandomDateTime

type TRandomDateTime struct{}

func (*TRandomDateTime) NextDate

func (c *TRandomDateTime) NextDate(min time.Time, max time.Time) time.Time

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: time.Time - minimum range value
	- max: time.Time - maximum range value
Returns: time.Time  - a random Date value.

func (*TRandomDateTime) NextDateTime

func (c *TRandomDateTime) NextDateTime(min time.Time, max time.Time) time.Time

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: time.Time  minimum range value
	- max: time.Time - maximum range value
Returns: time.Time a random Date and Time value.

func (*TRandomDateTime) UpdateDateTime

func (c *TRandomDateTime) UpdateDateTime(value time.Time, interval int64) time.Time

UpdateDateTime updates (drifts) a Date value within specified range defined

Parameters:
	- value: time.Time - value to drift.
	- interval: int64 - a range in milliseconds. Default: 10 days
Returns: time.Time Date value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL