Add library for generating fake data

This commit is contained in:
Tobie Morgan Hitchcock 2017-06-09 18:59:03 +01:00
parent f7318dbbe8
commit 8ed69a8774
13 changed files with 4371 additions and 0 deletions

23
util/fake/bool.go Normal file
View file

@ -0,0 +1,23 @@
// Copyright © 2016 Abcum Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package fake
func Bool() bool {
return New().Bool()
}
func (f *Faker) Bool() bool {
return 0.5 <= f.r.Float64()
}

75
util/fake/char.go Normal file
View file

@ -0,0 +1,75 @@
// Copyright © 2016 Abcum Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package fake
var vowels = "aeoui"
var consonants = "bcdfghjklmnpqrstvwxyz"
var lowerchars = "abcdefghijklmnopqrstuvwxyz"
var upperchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
var alphachars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
var alphanumbs = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
func Alphanum() string {
return New().Alphanum()
}
func (f *Faker) Alphanum() string {
return string(alphanumbs[f.r.Intn(len(alphanumbs))])
}
func Char() string {
return New().Char()
}
func (f *Faker) Char() string {
return string(alphachars[f.r.Intn(len(alphachars))])
}
func CharLower() string {
return New().CharLower()
}
func (f *Faker) CharLower() string {
return string(lowerchars[f.r.Intn(len(lowerchars))])
}
func CharUpper() string {
return New().CharUpper()
}
func (f *Faker) CharUpper() string {
return string(upperchars[f.r.Intn(len(upperchars))])
}
func CharVowel() string {
return New().CharVowel()
}
func (f *Faker) CharVowel() string {
return string(vowels[f.r.Intn(len(vowels))])
}
func CharConsonant() string {
return New().CharConsonant()
}
func (f *Faker) CharConsonant() string {
return string(consonants[f.r.Intn(len(consonants))])
}

35
util/fake/company.go Normal file

File diff suppressed because one or more lines are too long

33
util/fake/fake.go Normal file
View file

@ -0,0 +1,33 @@
// Copyright © 2016 Abcum Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package fake
import (
"math/rand"
"time"
)
func init() {
rand.Seed(time.Now().UTC().UnixNano())
}
type Faker struct {
r *rand.Rand
}
func New() *Faker {
s := time.Now().UTC().UnixNano()
return &Faker{r: rand.New(rand.NewSource(s))}
}

3560
util/fake/latin.go Normal file

File diff suppressed because it is too large Load diff

143
util/fake/location.go Normal file
View file

@ -0,0 +1,143 @@
// Copyright © 2016 Abcum Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package fake
import (
"fmt"
"strings"
)
var names = []string{"Home", "Work", "Business", "Personal"}
var streets = []string{"Avenue", "Boulevard", "Center", "Circle", "Court", "Drive", "Extension", "Glen", "Grove", "Heights", "Highway", "Junction", "Key", "Lane", "Loop", "Manor", "Mill", "Park", "Parkway", "Pass", "Path", "Pike", "Place", "Plaza", "Point", "Ridge", "River", "Road", "Square", "Street", "Terrace", "Trail", "Turnpike", "View", "Way"}
var states = []string{"Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming"}
var counties = []string{"Bath and North East Somerset", "Aberdeenshire", "Anglesey", "Angus", "Bedford", "Blackburn with Darwen", "Blackpool", "Bournemouth", "Bracknell Forest", "Brighton & Hove", "Bristol", "Buckinghamshire", "Cambridgeshire", "Carmarthenshire", "Central Bedfordshire", "Ceredigion", "Cheshire East", "Cheshire West and Chester", "Clackmannanshire", "Conwy", "Cornwall", "County Antrim", "County Armagh", "County Down", "County Durham", "County Fermanagh", "County Londonderry", "County Tyrone", "Cumbria", "Darlington", "Denbighshire", "Derby", "Derbyshire", "Devon", "Dorset", "Dumfries and Galloway", "Dundee", "East Lothian", "East Riding of Yorkshire", "East Sussex", "Edinburgh", "Essex", "Falkirk", "Fife", "Flintshire", "Gloucestershire", "Greater London", "Greater Manchester", "Gwent", "Gwynedd", "Halton", "Hampshire", "Hartlepool", "Herefordshire", "Hertfordshire", "Highlands", "Hull", "Isle of Wight", "Isles of Scilly", "Kent", "Lancashire", "Leicester", "Leicestershire", "Lincolnshire", "Lothian", "Luton", "Medway", "Merseyside", "Mid Glamorgan", "Middlesbrough", "Milton Keynes", "Monmouthshire", "Moray", "Norfolk", "North East Lincolnshire", "North Lincolnshire", "North Somerset", "North Yorkshire", "Northamptonshire", "Northumberland", "Nottingham", "Nottinghamshire", "Oxfordshire", "Pembrokeshire", "Perth and Kinross", "Peterborough", "Plymouth", "Poole", "Portsmouth", "Powys", "Reading", "Redcar and Cleveland", "Rutland", "Scottish Borders", "Shropshire", "Slough", "Somerset", "South Glamorgan", "South Gloucestershire", "South Yorkshire", "Southampton", "Southend-on-Sea", "Staffordshire", "Stirlingshire", "Stockton-on-Tees", "Stoke-on-Trent", "Strathclyde", "Suffolk", "Surrey", "Swindon", "Telford and Wrekin", "Thurrock", "Torbay", "Tyne and Wear", "Warrington", "Warwickshire", "West Berkshire", "West Glamorgan", "West Lothian", "West Midlands", "West Sussex", "West Yorkshire", "Western Isles", "Wiltshire", "Windsor and Maidenhead", "Wokingham", "Worcestershire", "Wrexham", "York"}
var countries = []string{"Afghanistan", "Åland Islands", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua & Barbuda", "Argentina", "Armenia", "Aruba", "Ascension Island", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia & Herzegovina", "Botswana", "Brazil", "British Indian Ocean Territory", "British Virgin Islands", "Brunei", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Canary Islands", "Cape Verde", "Caribbean Netherlands", "Cayman Islands", "Central African Republic", "Ceuta & Melilla", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo - Brazzaville", "Congo - Kinshasa", "Cook Islands", "Costa Rica", "Côte d'Ivoire", "Croatia", "Cuba", "Curaçao", "Cyprus", "Czech Republic", "Denmark", "Diego Garcia", "Djibouti", "Dominica", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Islands", "Faroe Islands", "Fiji", "Finland", "France", "French Guiana", "French Polynesia", "French Southern Territories", "Gabon", "Gambia", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guernsey", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Honduras", "Hong Kong SAR China", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Isle of Man", "Israel", "Italy", "Jamaica", "Japan", "Jersey", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Kosovo", "Kuwait", "Kyrgyzstan", "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macau SAR China", "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Martinique", "Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Montenegro", "Montserrat", "Morocco", "Mozambique", "Myanmar (Burma)", "Namibia", "Nauru", "Nepal", "Netherlands", "New Caledonia", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "North Korea", "Northern Mariana Islands", "Norway", "Oman", "Pakistan", "Palau", "Palestinian Territories", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Pitcairn Islands", "Poland", "Portugal", "Puerto Rico", "Qatar", "Réunion", "Romania", "Russia", "Rwanda", "Samoa", "San Marino", "São Tomé and Príncipe", "Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone", "Singapore", "Sint Maarten", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "South Georgia & South Sandwich Islands", "South Korea", "South Sudan", "Spain", "Sri Lanka", "St. Barthélemy", "St. Helena", "St. Kitts & Nevis", "St. Lucia", "St. Martin", "St. Pierre & Miquelon", "St. Vincent & Grenadines", "Sudan", "Suriname", "Svalbard & Jan Mayen", "Swaziland", "Sweden", "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "Timor-Leste", "Togo", "Tokelau", "Tonga", "Trinidad & Tobago", "Tristan da Cunha", "Tunisia", "Turkey", "Turkmenistan", "Turks & Caicos Islands", "Tuvalu", "U.S. Outlying Islands", "U.S. Virgin Islands", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "Uruguay", "Uzbekistan", "Vanuatu", "Vatican City", "Venezuela", "Vietnam", "Wallis & Futuna", "Western Sahara", "Yemen", "Zambia", "Zimbabwe"}
func LocationName() string {
return New().LocationName()
}
func (f *Faker) LocationName() string {
return names[f.r.Intn(len(names))]
}
func LocationAddress() string {
return New().LocationAddress()
}
func (f *Faker) LocationAddress() string {
return fmt.Sprintf("%d %s",
f.IntegerBetween(1, 250),
f.LocationStreet(),
)
}
func LocationStreet() string {
return New().LocationStreet()
}
func (f *Faker) LocationStreet() string {
return fmt.Sprintf("%s %s",
strings.Title(f.Word()),
streets[f.r.Intn(len(streets))],
)
}
func LocationCity() string {
return New().LocationCity()
}
func (f *Faker) LocationCity() string {
return strings.Title(f.Word())
}
func LocationState() string {
return New().LocationState()
}
func (f *Faker) LocationState() string {
return states[f.r.Intn(len(states))]
}
func LocationCounty() string {
return New().LocationCounty()
}
func (f *Faker) LocationCounty() string {
return counties[f.r.Intn(len(counties))]
}
func LocationZipcode() string {
return New().LocationZipcode()
}
func (f *Faker) LocationZipcode() string {
return fmt.Sprintf("%s%s %d",
f.CharUpper(),
f.CharUpper(),
f.IntegerBetween(10000, 99999),
)
}
func LocationPostcode() string {
return New().LocationPostcode()
}
func (f *Faker) LocationPostcode() string {
return fmt.Sprintf("%s%s%d %d%s%s",
f.CharUpper(),
f.CharUpper(),
f.IntegerBetween(0, 20),
f.IntegerBetween(0, 99),
f.CharUpper(),
f.CharUpper(),
)
}
func LocationCountry() string {
return New().LocationCountry()
}
func (f *Faker) LocationCountry() string {
return countries[f.r.Intn(len(countries))]
}
func LocationAltitude() float64 {
return New().LocationAltitude()
}
func (f *Faker) LocationAltitude() float64 {
return f.r.Float64() * 8848
}
func LocationLatitude() float64 {
return New().LocationLatitude()
}
func (f *Faker) LocationLatitude() float64 {
return f.r.Float64()*180 - 90
}
func LocationLongitude() float64 {
return New().LocationLongitude()
}
func (f *Faker) LocationLongitude() float64 {
return f.r.Float64()*360 - 180
}

130
util/fake/lorem.go Normal file
View file

@ -0,0 +1,130 @@
// Copyright © 2016 Abcum Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package fake
import (
"strings"
)
func (f *Faker) rand() int {
r := f.r.Float32() * 100
switch {
case r < 1.939:
return 1
case r < 19.01:
return 2
case r < 38.00:
return 3
case r < 50.41:
return 4
case r < 61.00:
return 5
case r < 70.09:
return 6
case r < 78.97:
return 7
case r < 85.65:
return 8
case r < 90.87:
return 9
case r < 95.05:
return 10
case r < 97.27:
return 11
case r < 98.67:
return 12
case r < 100.0:
return 13
}
return 2
}
func (f *Faker) word(size int) string {
if size < 1 {
size = 1
}
if size > 13 {
size = 13
}
for n := f.r.Int() % len(latin); ; n++ {
if n >= len(latin)-1 {
n = 0
}
if len(latin[n]) == size {
return latin[n]
}
}
return ""
}
func Lorem() string {
return New().Lorem()
}
func (f *Faker) Lorem() string {
return f.word(f.IntegerBetween(4, 13))
}
func Sentence() string {
return New().Sentence()
}
func (f *Faker) Sentence() string {
return f.SentenceBetween(5, 22)
}
func SentenceBetween(beg, end int) string {
return New().SentenceBetween(beg, end)
}
func (f *Faker) SentenceBetween(beg, end int) string {
s := f.IntegerBetween(beg, end)
w := []string{}
for i, c := 0, 0; i < s; i++ {
if i == 0 {
w = append(w, strings.Title(f.word(f.rand())))
} else {
w = append(w, f.word(f.rand()))
}
if c >= 2 || i <= 2 || i >= s-1 {
continue
}
if f.r.Int()%s == 0 {
w[i-1] += ","
c++
}
}
return strings.Join(w, " ") + "."
}
func Paragraph() string {
return New().Paragraph()
}
func (f *Faker) Paragraph() string {
return f.ParagraphBetween(3, 7)
}
func ParagraphBetween(beg, end int) string {
return New().ParagraphBetween(beg, end)
}
func (f *Faker) ParagraphBetween(beg, end int) string {
w := []string{}
for i := 0; i < f.IntegerBetween(beg, end); i++ {
w = append(w, f.Sentence())
}
return strings.Join(w, " ")
}

47
util/fake/number.go Normal file
View file

@ -0,0 +1,47 @@
// Copyright © 2016 Abcum Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package fake
func Integer() int {
return New().Integer()
}
func (f *Faker) Integer() int {
return f.r.Int()
}
func IntegerBetween(beg, end int) int {
return New().IntegerBetween(beg, end)
}
func (f *Faker) IntegerBetween(beg, end int) int {
return f.r.Intn(end-beg) + beg
}
func Decimal() float64 {
return New().Decimal()
}
func (f *Faker) Decimal() float64 {
return f.r.NormFloat64()
}
func DecimalBetween(beg, end float64) float64 {
return New().DecimalBetween(beg, end)
}
func (f *Faker) DecimalBetween(beg, end float64) float64 {
return f.r.Float64()*(end-beg) + beg
}

112
util/fake/person.go Normal file

File diff suppressed because one or more lines are too long

87
util/fake/string.go Normal file
View file

@ -0,0 +1,87 @@
// Copyright © 2016 Abcum Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package fake
import (
"bytes"
"fmt"
)
func String() string {
return New().String()
}
func (f *Faker) String() string {
var b bytes.Buffer
for i := 0; i < f.IntegerBetween(1, 100); i++ {
b.WriteString(f.Alphanum())
}
return b.String()
}
func StringLength(size int) string {
return New().StringLength(size)
}
func (f *Faker) StringLength(size int) string {
var b bytes.Buffer
for i := 0; i < size; i++ {
b.WriteString(f.Alphanum())
}
return b.String()
}
func StringBetween(beg, end int) string {
return New().StringBetween(beg, end)
}
func (f *Faker) StringBetween(beg, end int) string {
var b bytes.Buffer
for i := 0; i < f.IntegerBetween(beg, end); i++ {
b.WriteString(f.Alphanum())
}
return b.String()
}
func Syllable() string {
return New().Syllable()
}
func (f *Faker) Syllable() string {
if f.Bool() {
switch f.Bool() {
case true:
return fmt.Sprintf("%s%s", f.CharVowel(), f.CharConsonant())
case false:
return fmt.Sprintf("%s%s", f.CharConsonant(), f.CharVowel())
}
}
return fmt.Sprintf("%s%s%s", f.CharConsonant(), f.CharVowel(), f.CharConsonant())
}
func Word() string {
return New().Word()
}
func (f *Faker) Word() string {
var str [4]string
for i := 0; i < 4; i++ {
str[i] = ""
}
for i := 0; i < f.IntegerBetween(2, 4); i++ {
str[i] = f.Syllable()
}
return fmt.Sprintf("%s%s%s%s", str[0], str[1], str[2], str[3])
}

39
util/fake/time.go Normal file
View file

@ -0,0 +1,39 @@
// Copyright © 2016 Abcum Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package fake
import (
"math"
"time"
)
func Time() time.Time {
return New().Time()
}
func (f *Faker) Time() time.Time {
n := int64(f.IntegerBetween(0, math.MaxInt64))
return time.Unix(0, n)
}
func TimeBetween(beg, end time.Time) time.Time {
return New().TimeBetween(beg, end)
}
func (f *Faker) TimeBetween(beg, end time.Time) time.Time {
b := int(beg.UnixNano())
e := int(end.UnixNano())
n := int64(f.IntegerBetween(b, e))
return time.Unix(0, n)
}

27
util/fake/uuid.go Normal file
View file

@ -0,0 +1,27 @@
// Copyright © 2016 Abcum Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package fake
import (
"github.com/satori/go.uuid"
)
func Uuid() string {
return uuid.NewV4().String()
}
func (f *Faker) Uuid() string {
return uuid.NewV4().String()
}

60
util/fake/web.go Normal file
View file

@ -0,0 +1,60 @@
// Copyright © 2016 Abcum Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package fake
import (
"fmt"
)
var tlds = []string{"com", "org", "edu", "gov", "co.uk", "net", "io", "ac", "ad", "ae", "af", "ag", "ai", "al", "am", "an", "ao", "aq", "ar", "as", "at", "au", "aw", "ax", "az", "ba", "bb", "bd", "be", "bf", "bg", "bh", "bi", "bj", "bm", "bn", "bo", "bq", "br", "bs", "bt", "bv", "bw", "by", "bz", "ca", "cc", "cd", "cf", "cg", "ch", "ci", "ck", "cl", "cm", "cn", "co", "cr", "cu", "cv", "cw", "cx", "cy", "cz", "de", "dj", "dk", "dm", "do", "dz", "ec", "ee", "eg", "eh", "er", "es", "et", "eu", "fi", "fj", "fk", "fm", "fo", "fr", "ga", "gb", "gd", "ge", "gf", "gg", "gh", "gi", "gl", "gm", "gn", "gp", "gq", "gr", "gs", "gt", "gu", "gw", "gy", "hk", "hm", "hn", "hr", "ht", "hu", "id", "ie", "il", "im", "in", "io", "iq", "ir", "is", "it", "je", "jm", "jo", "jp", "ke", "kg", "kh", "ki", "km", "kn", "kp", "kr", "kw", "ky", "kz", "la", "lb", "lc", "li", "lk", "lr", "ls", "lt", "lu", "lv", "ly", "ma", "mc", "md", "me", "mg", "mh", "mk", "ml", "mm", "mn", "mo", "mp", "mq", "mr", "ms", "mt", "mu", "mv", "mw", "mx", "my", "mz", "na", "nc", "ne", "nf", "ng", "ni", "nl", "no", "np", "nr", "nu", "nz", "om", "pa", "pe", "pf", "pg", "ph", "pk", "pl", "pm", "pn", "pr", "ps", "pt", "pw", "py", "qa", "re", "ro", "rs", "ru", "rw", "sa", "sb", "sc", "sd", "se", "sg", "sh", "si", "sj", "sk", "sl", "sm", "sn", "so", "sr", "ss", "st", "su", "sv", "sx", "sy", "sz", "tc", "td", "tf", "tg", "th", "tj", "tk", "tl", "tm", "tn", "to", "tp", "tr", "tt", "tv", "tw", "tz", "ua", "ug", "uk", "us", "uy", "uz", "va", "vc", "ve", "vg", "vi", "vn", "vu", "wf", "ws", "ye", "yt", "za", "zm", "zw"}
func Avatar() string {
return New().Avatar()
}
func (f *Faker) Avatar() string {
return fmt.Sprintf("%s%d",
"https://www.gravatar.com/avatar/",
f.StringLength(32),
)
}
func Domain() string {
return New().Domain()
}
func (f *Faker) Domain() string {
return f.Word() + "." + f.Tld()
}
func Tld() string {
return New().Tld()
}
func (f *Faker) Tld() string {
return tlds[f.r.Intn(len(tlds))]
}
func Url() string {
return New().Url()
}
func (f *Faker) Url() string {
return fmt.Sprintf("https://%s/%s/%s",
f.Domain(),
f.Word(),
f.Word(),
)
}