faker

package
v0.0.0-...-406a352 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Address

func Address(conn *sql.DB) map[string]string

func AddressColumns

func AddressColumns(conn *sql.DB, columns ...string) []map[string]string

func Age

func Age() string

func AirPort3Code

func AirPort3Code() string

机场的IATA三位编码

func AirPort4Code

func AirPort4Code() string

机场的ICAO四位编码

func AirPortCity

func AirPortCity() string

机场所在的城市

func AirPortCityPinyin

func AirPortCityPinyin() string

机场所在城市的拼音

func AirPortInfo

func AirPortInfo() map[string]string

机场信息

func AirPortName

func AirPortName() string

机场名字

func AirlineInfo

func AirlineInfo() map[string]string

航空公司代号,名称

func AirlineName

func AirlineName() string

航空公司名称

func AreaCode

func AreaCode(langs ...string) string

AreaCode will generate a random areacode string

func BS

func BS() string

BS will generate a random company bs string

func BirthDay

func BirthDay() string

func BuzzWord

func BuzzWord() string

BuzzWord will generate a random company buzz word string

func CarBrand

func CarBrand(langs ...string) string

获取所有车辆品牌的名称

func ChromeUserAgent

func ChromeUserAgent() string

ChromeUserAgent will generate a random chrome browser user agent string

Example
Seed(11)
fmt.Println(ChromeUserAgent())
Output:

Mozilla/5.0 (X11; Linux i686) AppleWebKit/5312 (KHTML, like Gecko) Chrome/39.0.836.0 Mobile Safari/5312

func CityCode

func CityCode() string

中国长途区号

func Color

func Color(langs ...string) string

Color will generate a random color string

func Company

func Company() (company string)

Company will generate a random company name string

func CompanySuffix

func CompanySuffix() string

CompanySuffix will generate a random company suffix string

func ConnectSqlite

func ConnectSqlite(dbPath string) (*sql.DB, error)

返回数据库连接, 若成功第二个参数为空字符串, 否则第二个参数为报错信息

func CreateConn

func CreateConn(dbPath string) *sql.DB

func Date

func Date() time.Time

Date will generate a random time.Time struct

Example
Seed(11)
fmt.Println(Date())
Output:

1989-01-07 04:14:25.685339029 +0000 UTC

func DateRange

func DateRange(start, end time.Time) time.Time

DateRange will generate a random time.Time struct between a start and end date

Example
Seed(11)
fmt.Println(DateRange(time.Unix(0, 484633944473634951), time.Unix(0, 1431318744473668209))) // May 10, 1985 years to May 10, 2015
Output:

2012-02-04 14:10:37.166933216 +0000 UTC

func Day

func Day() int

Day will generate a random day between 1 - 31

Example
Seed(11)
fmt.Println(Day())
Output:

12

func DeviceID

func DeviceID() string

//采集设备ID、固定21位、前9位为安全厂商ID(如FIBERHOME),后12位为采集设备MAC,规则同MAC、所有字母大写

func DomainName

func DomainName() string

DomainName will generate a random url domain name

func DomainSuffix

func DomainSuffix() string

DomainSuffix will generate a random domain suffix

func Email

func Email() string

Email will generate a random email string

func FirefoxUserAgent

func FirefoxUserAgent() string

FirefoxUserAgent will generate a random firefox broswer user agent string

Example
Seed(11)
fmt.Println(FirefoxUserAgent())
Output:

Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_8_3 rv:7.0) Gecko/1989-07-01 Firefox/37.0

func FirstName

func FirstName(langs ...string) string

FirstName will generate a random first name

func Float32

func Float32() float32

Float32 will generate a random float32 value

Example
Seed(11)
fmt.Println(Float32())
Output:

3.1128167e+37

func Float64

func Float64() float64

Float64 will generate a random float64 value

Example
Seed(11)
fmt.Println(Float64())
Output:

1.644484108270445e+307

func Gender

func Gender(langs ...string) string

Color will generate a random color string

func HTTPMethod

func HTTPMethod() string

HTTPMethod will generate a random http method

func Hour

func Hour() int

Hour will generate a random hour - in military time

Example
Seed(11)
fmt.Println(Hour())
Output:

0

func IMID

func IMID() string

func IPv4Address

func IPv4Address() string

IPv4Address will generate a random version 4 ip address

func IPv6Address

func IPv6Address() string

IPv6Address will generate a random version 6 ip address

func IdCard

func IdCard() string

func Imei

func Imei() string

IMEI(GSM网络)即EQUIREMENT_ID,15-17位、纯数字

func Imsi

func Imsi() string

IMSI是15位的十进制数, 结构为: MCC + MNC + MSIN 国内为460开头、<=15、纯数字(国内一般为15位,国际规范为不超过15位) 暂时只做国内的

func Int16

func Int16() int16

Int16 will generate a random int16 value

Example
Seed(11)
fmt.Println(Int16())
Output:

2200

func Int32

func Int32() int32

Int32 will generate a random int32 value

Example
Seed(11)
fmt.Println(Int32())
Output:

-1072427943

func Int64

func Int64() int64

Int64 will generate a random int64 value

Example
Seed(11)
fmt.Println(Int64())
Output:

-8379641344161477543

func Int8

func Int8() int8

Int8 will generate a random Int8 value

Example
Seed(11)
fmt.Println(Int8())
Output:

24

func Job

func Job(langs ...string) string

func LastName

func LastName(langs ...string) string

LastName will generate a random last name

func Letter

func Letter() string

Letter will generate a single random lower case letter

Example
Seed(11)
fmt.Println(Letter())
Output:

g

func Lexify

func Lexify(str string) string

Lexify will replace ? will random generated letters

Example
Seed(11)
fmt.Println(Lexify("?????"))
Output:

gbrma

func Luhn

func Luhn(preNumArr []int) int

Luhn算法

func MacAddress

func MacAddress(sep string, letterType bool) string

MacAddress will generate a random mac address 根据sep确定分隔符返回, letterType=true返回大写字母, false返回小写字母

func Meid

func Meid(letterType bool) string

MEID(CDMA网络):固定14位,16进制,数字+[A-F]或[a-f],例子:A000008C057C13 letterType=true返回大写字母, false返回小写字母

func Minute

func Minute() int

Minute will generate a random minute

Example
Seed(11)
fmt.Println(Minute())
Output:

0

func MobilePhone

func MobilePhone(langs ...string) string

移动电话号码,中文会有前缀,暂时只支持中国的

func Month

func Month() string

Month will generate a random month string

Example
Seed(11)
fmt.Println(Month())
Output:

January

func Name

func Name(langs ...string) string

Name will generate a random First and Last Name

func NanoSecond

func NanoSecond() int

NanoSecond will generate a random nano second

Example
Seed(11)
fmt.Println(NanoSecond())
Output:

196446360

func NickName

func NickName() string

func NowDate

func NowDate() string

func NowTimeStamp

func NowTimeStamp() string

当前时间戳

func Number

func Number(min int, max int) int

Number will generate a random number between given min And max

Example
Seed(11)
fmt.Println(Number(50, 23456))
Output:

14866

func Numerify

func Numerify(str string) string

Numerify will replace # with random numerical values

Example
Seed(11)
fmt.Println(Numerify("###-###-####"))
Output:

328-727-1570

func OperaUserAgent

func OperaUserAgent() string

OperaUserAgent will generate a random opera browser user agent string

Example
Seed(11)
fmt.Println(OperaUserAgent())
Output:

Opera/8.39 (Macintosh; U; PPC Mac OS X 10_8_7; en-US) Presto/2.9.335 Version/10.00

func PassWord

func PassWord(lower bool, upper bool, numeric bool, special bool, space bool, length int) string

Password will generate a random password

func QuerySqlite

func QuerySqlite(conn *sql.DB, querySql string, args ...interface{}) ([]map[string]string, error)

执行查询SQL, 返回查询结果

func RandBool

func RandBool(a []bool) bool

RandBool will take in a slice of bool and return a randomly selected value

func RandMacAddress

func RandMacAddress() string

随机返回大小写,多种分隔符的mac地址

func RandMeid

func RandMeid() string

随机返回大小写,多种分隔符的meid地址

func RandString

func RandString(a []string) string

RandString will take in a slice of string and return a randomly selected value

func SafariUserAgent

func SafariUserAgent() string

SafariUserAgent will generate a random safari browser user agent string

Example
Seed(11)
fmt.Println(SafariUserAgent())
Output:

Mozilla/5.0 (iPad; CPU OS 8_3_2 like Mac OS X; en-US) AppleWebKit/531.15.6 (KHTML, like Gecko) Version/4.0.5 Mobile/8B120 Safari/6531.15.6

func SeatOfFlight

func SeatOfFlight() string

func SeatOfTrain

func SeatOfTrain() string

func Second

func Second() int

Second will generate a random second

Example
Seed(11)
fmt.Println(Second())
Output:

0

func Seed

func Seed(seed int64)

Seed random. Setting seed to 0 will use time.Now().UnixNano()

func ShuffleInts

func ShuffleInts(a []int)

ShuffleInts will randomize a slice of ints

Example
Seed(11)

ints := []int{52, 854, 941, 74125, 8413, 777, 89416, 841657}
ShuffleInts(ints)
fmt.Println(ints)
Output:

[74125 777 941 89416 8413 854 52 841657]

func ShuffleStrings

func ShuffleStrings(a []string)

ShuffleStrings will randomize a slice of strings

Example
Seed(11)
strings := []string{"happy", "times", "for", "everyone", "have", "a", "good", "day"}
ShuffleStrings(strings)
fmt.Println(strings)
Output:

[everyone a for good have times happy day]

func SpecialTellPhone

func SpecialTellPhone() string

特殊号码

func TelPhone

func TelPhone(langs ...string) string

固定电话号码,暂时只支持中国的(不包括特殊号码)

func TrainTripis

func TrainTripis() string

func URL

func URL() string

URL will generate a random url string

func Uint16

func Uint16() uint16

Uint16 will generate a random uint16 value

Example
Seed(11)
fmt.Println(Uint16())
Output:

34968

func Uint32

func Uint32() uint32

Uint32 will generate a random uint32 value

Example
Seed(11)
fmt.Println(Uint32())
Output:

1075055705

func Uint64

func Uint64() uint64

Uint64 will generate a random uint64 value

Example
Seed(11)
fmt.Println(Uint64())
Output:

843730692693298265

func Uint8

func Uint8() uint8

Uint8 will generate a random uint8 value

Example
Seed(11)
fmt.Println(Uint8())
Output:

152

func UserAgent

func UserAgent() string

UserAgent will generate a random broswer user agent

Example
Seed(11)
fmt.Println(UserAgent())
Output:

Mozilla/5.0 (Windows NT 5.0) AppleWebKit/5362 (KHTML, like Gecko) Chrome/37.0.834.0 Mobile Safari/5362

func UserName

func UserName() string

Username will genrate a random username based upon picking a random lastname and random numbers at the end

func Voyage

func Voyage() string

航班号,航次,航班

func WebSite

func WebSite() string

func WeekDay

func WeekDay() string

WeekDay will generate a random weekday string (Monday-Sunday)

Example
Seed(11)
fmt.Println(WeekDay())
Output:

Friday

func Year

func Year() int

Year will generate a random year between 1900 - current year

Example
Seed(11)
fmt.Println(Year())
Output:

1989

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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