-
Notifications
You must be signed in to change notification settings - Fork 3
/
config.go
43 lines (34 loc) · 833 Bytes
/
config.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
package config
import (
"github.com/spf13/viper"
"log"
)
// data path
var (
EntryPoints []string
MaxDepth int
Parallelism int
Delay int64
DataPath string
IndexPath string
HttpAddress string
)
// load config
func init() {
viper.SetConfigName(".config")
viper.SetConfigType("yaml")
// if in project root
viper.AddConfigPath(".")
// if you are in cmd/crawler or internal/crawler
viper.AddConfigPath("../..")
if err := viper.ReadInConfig(); err != nil {
log.Fatalf("Error reading config file, %s", err)
}
EntryPoints = viper.GetStringSlice("entryPoint")
MaxDepth = viper.GetInt("maxDepth")
Parallelism = viper.GetInt("parallelism")
Delay = viper.GetInt64("delay")
DataPath = viper.GetString("dataPath")
IndexPath = viper.GetString("indexPath")
HttpAddress = viper.GetString("httpAddress")
}