-
Notifications
You must be signed in to change notification settings - Fork 12
/
init.go
44 lines (38 loc) · 855 Bytes
/
init.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
package main
import (
"flag"
"log"
"math/rand"
"runtime"
"github.com/alash3al/libsrchx"
"github.com/icrowley/fake"
)
func init() {
var err error
flag.Parse()
runtime.GOMAXPROCS(*flagWorkers)
store, err = srchx.NewStore(*flagEngine, *flagStoragePath)
if err != nil {
log.Fatal(err)
}
if *flagGenFakeData > 0 {
go func() {
ndx, _ := store.GetIndex("test/fake")
fake.SetLang("en")
for i := 0; i < *flagGenFakeData; i++ {
ndx.Put(map[string]interface{}{
"full_name": fake.FullName(),
"country": fake.Country(),
"brand": fake.Brand(),
"email": fake.EmailAddress(),
"ip": fake.IPv4(),
"industry": fake.Industry(),
"age": rand.Intn(100),
"salary": rand.Intn(20) * 1000,
"power": rand.Intn(10),
"family": rand.Intn(10),
})
}
}()
}
}