humantouch

package module
v0.1.28 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2021 License: MIT Imports: 10 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Humantouch

Go Reference

Installation

go get -u github.com/masv3971/humantouch

Example

package main

import (
    "github.com/masv3971/humantouch"
)

func main() {
    // Always seed rand!
	rand.Seed(time.Now().Unix())

    person, _ := humantouch.New(nil)

    person.RandomHuman()
    // *Person
}

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 BirthDay

type BirthDay struct {
	S string
	I int
}

BirthDay day data

type BirthMonth

type BirthMonth struct {
	S string
	I int
}

BirthMonth data

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

func New(config *Config) (*Client, error)

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) Female

func (c *Client) Female() (*Person, error)

Female return a female person, or error

func (*Client) Females

func (c *Client) Females(n int) ([]*Person, error)

Females return n slice of *Person

func (*Client) Male

func (c *Client) Male() (*Person, error)

Male return a male person, or error

func (*Client) Males

func (c *Client) Males(n int) ([]*Person, error)

Males return n slice of *Person

func (*Client) RandomHuman

func (c *Client) RandomHuman() (*Person, error)

RandomHuman return all kinds of humans, full span of age and gender

func (*Client) RandomHumans

func (c *Client) RandomHumans(n int) ([]*Person, error)

RandomHumans return a slice of female humans

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 Gender

type Gender struct {
	General string
	Ladok   int
}

Gender object

type LuhnNumber

type LuhnNumber struct {
	S string
	I int
}

LuhnNumber data

type Person

type Person struct {
	Firstname            string
	Lastname             string
	BirthYear            BirthYear
	BirthMonth           BirthMonth
	BirthDay             BirthDay
	SocialSecurityNumber *SocialSecurityNumber
	Gender               Gender
	Age                  int
}

Person object

type PersonConfig

type PersonConfig struct {
}

PersonConfig configuration for person

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

Directories

Path Synopsis
examples
simple_use command
sweden command

Jump to

Keyboard shortcuts

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