gofaker

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

README

go-faker

Inspired by faker, this is a faker library in go.

Changelog

for details, see version.go

How to use

1.Generate a random profile:
import (
	"fmt"

	g "github.com/guchengxi1994/go_faker"
)

func main() {
	p := g.Profile{
		Locale: "zh_CN",
	}
	p.Generate()
	fmt.Printf("p.ToString(): %v\n", p.ToString())
}


/* results
p.ToString(): 
                        姓名:谈芳, Fang Tan,
                        性别:男,
                        年龄:63,
                        手机号码:15896583855,
                        身份证号码:43090019580524577X,
                        家庭住址:上海市六盘水市清城区关岭街869座,
                        工作经历:2018-05~Now,趋势网络有限公司,停车管理员
                                  2014-11~2018-05,群英网络有限公司,审核员
                                  2007-05~2014-11,惠派国际公司网络有限公司,网页设计/制作/美工
                                  2007-04~2007-05,迪摩网络有限公司,工程/设备经理
                                  2005-02~2007-04,惠派国际公司网络有限公司,百货零售
                                  2003-08~2005-02,迪摩网络有限公司,化妆师
                                  1995-02~2003-08,通际名联网络有限公司,百货零售
                                  1986-12~1995-02,趋势网络有限公司,硫化工
                                  1986-11~1986-12,九方网络有限公司,驻唱/歌手
                                  1981-01~1986-11,迪摩网络有限公司,收货员

                        简介:我有很强的职责心,有很强的群众荣誉感,乐观开朗,有很好的人迹关系,能够认真对待生活,有熟练的护理技能与牢固的专业知识并能灵活运用
到实际工作中。我一向相信只要努力应对生活,心存一份感恩,再黑暗的地方也会有光明。我拥有的是年轻的激情,如果您把信任和期望给我,那么我的自信、我的激情,我的潜力
,将是您最满意的答案。
*/

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = "0.0.5"

v0.0.1 zh_CN address generator

v0.0.1+4 random alg

v0.0.2 ipv4 address generator

v0.0.2+1 location generator

v0.0.2+2 mobile(zh_CN) generator

v0.0.2+3 ssn(zh_CN) generator

v0.0.3 profile generator

v0.0.3+1 name generator

v0.0.4 education generator

v0.0.5 add education to profile

Functions

func GenerateIpV4Address

func GenerateIpV4Address(containDNSs bool) string

func GeneratePort

func GeneratePort(max int) string

func GenerateRandomAddress

func GenerateRandomAddress()

func GenerateRandomDate

func GenerateRandomDate(max, min int) (string, int)

func IsIpV4Valid

func IsIpV4Valid(ip string, containDNSs bool) bool

Types

type Address

type Address struct {
	PostcodeLength int
	Args           []float64 // weight
	UseWeighting   bool
	Locole         string
}

func (*Address) Address

func (addr *Address) Address(args ...float64) string

generate

func (*Address) BuildingNumber

func (addr *Address) BuildingNumber(length int) string

func (*Address) City

func (addr *Address) City(args ...float64) string

func (*Address) District

func (addr *Address) District(args ...float64) string

func (*Address) Province

func (addr *Address) Province(args ...float64) string

func (*Address) StreetAddress

func (addr *Address) StreetAddress(length int, args ...float64) string

func (*Address) StreetName

func (addr *Address) StreetName(args ...float64) string

type BaseAddress

type BaseAddress interface {
	City(args ...float64) string
	BuildingNumber(int) string
	District(args ...float64) string
	Postcode(int) string
	StreetName(args ...float64) string
	StreetAddress(args ...float64) string
	Country() string
	Province(args ...float64) string
}

type Company

type Company struct {
	Locale string
	Args   []float64 // weight
}

func (*Company) Generate

func (company *Company) Generate() string

type Experience

type Experience struct {
	StartTime   string `json:"startTime"`
	EndTime     string `json:"endTime"`
	Institution string `json:"institution"`
	Content     string `json:"content"`
}

func GenerateSchoolExperience

func GenerateSchoolExperience(grades int, currentAge int, locale string) ([]Experience, int)

grade > 0 primary school 6 years,

grade = 1 middle school 3 years,

grade = 2 high school 3 years,

grade = 3 university bachelor 4 years,

grade = 4 university master 3 years,

grade = 5 university doctor 4 years,

grade = 6 others 3 years 中专

grade = 7 others 5 years 大专

September to July

studyStartAge = one of [5,6,7,8]

func GenerateWorkExperiences

func GenerateWorkExperiences(times, years int, locale string) []Experience

times is the number join work

years is the number form when to now

func (*Experience) ToString

func (e *Experience) ToString() string

type Job

type Job struct {
	Locale string
}

func (*Job) Generate

func (job *Job) Generate() string

type Location

type Location struct {
	Longitude string // 经度  0-180
	Latitude  string // 维度  0-90
	WE        string
	NS        string
}

func (*Location) GetPositon

func (location *Location) GetPositon() string

type Mobile

type Mobile struct {
	Locale string
	City   string
}

func (*Mobile) Generate

func (mobile *Mobile) Generate(supplier string) string

type PersonName

type PersonName struct {
	Locale    string
	Firstname string
	Lastname  string
	Gender    bool
	Pinyin    string //only for chinese names
	// contains filtered or unexported fields
}

func (*PersonName) Generate

func (p *PersonName) Generate(args ...float64)

func (*PersonName) ToString

func (p *PersonName) ToString(withPinyin bool) string

type Profile

type Profile struct {
	Name            string `json:"name"`
	Gender          bool   `json:"gender"`
	IdNumber        string `json:"idNumber"`
	MobileNumber    string `json:"mobile"`
	Locale          string
	HomeAddress     string       `json:"homeAddress"`
	WorkExperiences []Experience `json:"workExperiences"`
	Description     string       `json:"description"`

	Age                  int          `json:"age"`
	EducationExperiences []Experience `json:"educationExperiences"` // 至少初中毕业,高中毕业,大学毕业,硕士,博士,大专
	// contains filtered or unexported fields
}

func (*Profile) FormatExperice

func (p *Profile) FormatExperice(t int) string

func (*Profile) Generate

func (p *Profile) Generate()

func (*Profile) ToString

func (p *Profile) ToString() string

type SSN

type SSN struct {
	Locale string
	MaxAge int
	MinAge int
	Gender bool
	// contains filtered or unexported fields
}

func (*SSN) Generate

func (ssn *SSN) Generate() string

func (*SSN) GenerateSequenceCode

func (ssn *SSN) GenerateSequenceCode() string

type School

type School struct {
	Type   int // 0 primary school ,1 middle school, 2 university 3 职业技术学院
	Locale string
}

func (*School) Generate

func (s *School) Generate() string

Directories

Path Synopsis
ssn

Jump to

Keyboard shortcuts

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