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" // GenderUndefined used when gender should be defined but can't be. GenderUndefined = "gender_undefined" )
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 ( // ErrAgeDistributionNotConfigured error about not configured age distribution ErrAgeDistributionNotConfigured = errors.New("ERR_AGE_DISTRIBUTION_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 ageDistribution
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 // Short year, 1970 -> 70
I int // Short year, 1970 -> 70
SLong string // Long year, 1970
ILong int // Long year, 1970
CenturyLongS string // Long century, 1970 -> 1900
CenturyLongI int // Long century, 1970 -> 1900
CenturyS string // Short century, 1970 -> 19
CenturyI int // Short century, 1970 -> 19
}
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{
DistributionCFG: &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 Veronika Abdull Hulda Gaute
Example (Random) ¶
rand.Seed(42)
human, _ := New(&Config{
DistributionCFG: &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 Lalle
func (*Client) RandomHuman ¶
RandomHuman return all kinds of humans, full span of age and gender
type Config ¶
type Config struct {
//Person *PersonConfig
DistributionCFG *DistributionCfg
SkatteverketTestSocialSecurityNumber bool
SkatteverketTestCoordinationNumber bool
}
Config holds configuration for humantouch
type Distribution ¶
type Distribution struct {
Age *DistributionCfg
// contains filtered or unexported fields
}
Distribution holds both Person and AgeDistribution
func (*Distribution) Females ¶
func (d *Distribution) Females(n int) ([]*Person, error)
Females return females according with the distribution
func (*Distribution) Males ¶
func (d *Distribution) Males(n int) ([]*Person, error)
Males return males according with the distribution
func (*Distribution) RandomHumans ¶
func (d *Distribution) RandomHumans(n int) ([]*Person, error)
RandomHumans return random humans according with the distribution
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 distribution
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.