Documentation ¶
Index ¶
Examples ¶
Constants ¶
View Source
const ( // GenderFemale for female gender GenderFemale = "female" // GenderMale for male gender GenderMale = "male" // GenderUnspecified for unspecified gender GenderUnspecified = "unspecified" )
Variables ¶
View Source
var ( // FirstnamesFemale consists of female firstnames FirstnamesFemale = []string{}/* 1086 elements not displayed */ // FirstnamesMale consists of male firstnames FirstnamesMale = []string{}/* 14761 elements not displayed */ // Lastnames consists of lastnames Lastnames = []string{}/* 1001 elements not displayed */ )
View Source
var ( // ErrAgeDistrubutionNotConfigured error about not configured age distrubution ErrAgeDistrubutionNotConfigured = errors.New("ERR_AGE_DISTRUBUTION_NOT_CONFIGURED") // ErrKeyCollide error for a key that collide ErrKeyCollide = errors.New("ERR_KEY_COLLIDE") // ErrNoKey error for key that does not exists ErrNoKey = errors.New("ERR_NO_KEY") )
Functions ¶
This section is empty.
Types ¶
type AgeData ¶
type AgeData struct { Weight float64 // contains filtered or unexported fields }
AgeData has data about each ageDistrubution
type BirthNumber ¶
type BirthNumber struct { N1s string N2s string N3s string N1i int N2i int N3i int Complete string }
BirthNumber data
type BirthYear ¶
type BirthYear struct { S string I int SLong string ILong int CenturyLongS string CenturyLongI int CenturyS string CenturyI int }
BirthYear data
type Client ¶
type Client struct { Distribution *Distribution // contains filtered or unexported fields }
Client holds humantouch object
func New ¶
New creates a new instance of humantouch
Example ¶
rand.Seed(42) human, _ := New(&Config{ DistrubutionCFG: &DistributionCfg{ Age0to10: AgeData{ Weight: 100, id: 0, }, Age10to20: AgeData{}, Age20to30: AgeData{}, Age30to40: AgeData{}, Age40to50: AgeData{}, Age50to60: AgeData{}, Age60to70: AgeData{}, Age70to80: AgeData{}, Age80to90: AgeData{}, Age90to100: AgeData{}, Age100to110: AgeData{}, }, }) // Return female human, or error female, _ := human.Female() //Return a male human, or error male, _ := human.Male() females, _ := human.Females(50) males, _ := human.Males(50) fmt.Println(female.Firstname, male.Firstname, females[0].Firstname, males[0].Firstname) femaleDist, _ := human.Distribution.Females(50) maleDist, _ := human.Distribution.Males(50) fmt.Println(femaleDist[0].Firstname, maleDist[0].Firstname)
Output: Frida Valentino Birgit Maths Dilan Rony
Example (Random) ¶
rand.Seed(42) human, _ := New(&Config{ DistrubutionCFG: &DistributionCfg{ Age0to10: AgeData{ Weight: 100, id: 0, }, }, }) randomDist, _ := human.Distribution.RandomHumans(50) fmt.Println("randomDist", randomDist[0].Firstname) randoms, _ := human.RandomHumans(50) fmt.Println("randoms", randoms[0].Firstname) random, _ := human.RandomHuman() fmt.Println("randomHuman", random.Firstname)
Output: randomDist Adolfina randoms Esad randomHuman Celina
func (*Client) RandomHuman ¶
RandomHuman return all kinds of humans, full span of age and gender
type Config ¶
type Config struct { //Person *PersonConfig DistrubutionCFG *DistributionCfg }
Config holds configuration for humantouch
type Distribution ¶
type Distribution struct { Age *DistributionCfg // contains filtered or unexported fields }
Distribution holds both Person and AgeDistrubution
func (*Distribution) Females ¶
func (d *Distribution) Females(n int) ([]*Person, error)
Females return females according with the distrubution
func (*Distribution) Males ¶
func (d *Distribution) Males(n int) ([]*Person, error)
Males return males according with the distrubution
func (*Distribution) RandomHumans ¶
func (d *Distribution) RandomHumans(n int) ([]*Person, error)
RandomHumans return random humans according with the distrubution
type DistributionCfg ¶
type DistributionCfg struct { Age0to10 AgeData Age10to20 AgeData Age20to30 AgeData Age30to40 AgeData Age40to50 AgeData Age50to60 AgeData Age60to70 AgeData Age70to80 AgeData Age80to90 AgeData Age90to100 AgeData Age100to110 AgeData }
DistributionCfg holds configuration regarding the age distrubution
type Person ¶
type Person struct { Firstname string Lastname string BirthYear BirthYear BirthMonth BirthMonth BirthDay BirthDay SocialSecurityNumber *SocialSecurityNumber Gender Gender Age int }
Person object
type SocialSecurityNumber ¶
type SocialSecurityNumber struct { Swedish12 *SwedishNIN Swedish10 *SwedishNIN SwedishTemp *SwedishNIN }
SocialSecurityNumber holds
type SwedishNIN ¶
type SwedishNIN struct { BirthNumber BirthNumber LuhnNumber LuhnNumber Complete string Delimiter string }
SwedishNIN is the object to store swedish socialnumber
Source Files ¶
Click to show internal directories.
Click to hide internal directories.