forked from parsyl/parquet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
people.go
98 lines (84 loc) · 1.5 KB
/
people.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package main
import (
"math"
"math/rand"
"time"
)
func init() {
rand.Seed(time.Now().UnixNano())
}
var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
func reallyRandString(n int) *string {
if rand.Intn(2) == 0 {
return nil
}
s := randString(n)
return &s
}
func randString(n int) string {
b := make([]rune, n)
for i := range b {
b[i] = letterRunes[rand.Intn(len(letterRunes))]
}
return string(b)
}
func newPerson(i int) Person {
var age *int32
if i%2 == 0 {
a := int32(20 + i%5)
age = &a
}
var sadness *int64
if i%3 == 0 {
s := int64(i + 5)
sadness = &s
}
var lameness *float32
if rand.Intn(2) == 0 {
l := rand.Float32()
lameness = &l
}
var keen *bool
if i%5 == 0 {
b := true
keen = &b
}
var anv *uint64
if i%3 == 0 {
x := math.MaxUint64 - uint64(i*100)
anv = &x
}
var hobby *Hobby
if i%2 == 0 {
d := int32(i % 10)
hobby = &Hobby{
Name: randString(10),
Difficulty: &d,
}
}
// nFriends := rand.Int31n(4)
// friends := make([]Being, nFriends)
// for i := range friends {
// d := rand.Int31n(100)
// friends[i] = Being{
// ID: int32(rand.Int()),
// Age: &d,
// }
// }
return Person{
Being: Being{
ID: int32(i),
Age: age,
},
Happiness: int64(i * 2),
Sadness: sadness,
Code: reallyRandString(8),
Funkiness: rand.Float32(),
Lameness: lameness,
Keen: keen,
Birthday: uint32(i * 1000),
Anniversary: anv,
Hobby: hobby,
//Friends: friends,
}
}