forked from icrowley/fake
-
Notifications
You must be signed in to change notification settings - Fork 2
/
internet.go
60 lines (51 loc) · 1.36 KB
/
internet.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package fake
import (
"math/rand"
"strconv"
"strings"
)
// UserName generates user name in one of the following forms
// first name + last name, letter + last names or concatenation of from 1 to 3 lowercased words
func UserName() string {
gender := randGender()
switch rand.Intn(3) {
case 0:
return lookup("en", gender+"_first_names", false) + lookup(lang, gender+"_last_names", false)
case 1:
return Character() + lookup(lang, gender+"_last_names", false)
default:
return strings.Replace(WordsN(rand.Intn(3)+1), " ", "_", -1)
}
}
// TopLevelDomain generates random top level domain
func TopLevelDomain() string {
return lookup(lang, "top_level_domains", true)
}
// DomainName generates random domain name
func DomainName() string {
return Company() + "." + TopLevelDomain()
}
// EmailAddress generates email address
func EmailAddress() string {
return UserName() + "@" + DomainName()
}
// EmailSubject generates random email subject
func EmailSubject() string {
return Sentence()
}
// EmailBody generates random email body
func EmailBody() string {
return Paragraphs()
}
// DomainZone generates random domain zone
func DomainZone() string {
return lookup(lang, "domain_zones", true)
}
// IPv4 generates IPv4 address
func IPv4() string {
ip := make([]string, 4)
for i := 0; i < 4; i++ {
ip[i] = strconv.Itoa(rand.Intn(256))
}
return strings.Join(ip, ".")
}