-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.go
36 lines (32 loc) · 823 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
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
)
// Config ...
type Config struct {
Connections map[string]*Connection `json:"connections"`
Errors uint64 `json:"errors"`
Nulls bool `json:"nulls"`
Page int `json:"page"`
Quiet bool `json:"quiet"`
Retries uint64 `json:"retries"`
Workers int `json:"workers"`
}
var config Config = Config{
Errors: defaultErrors,
Page: defaultPage,
Retries: defaultRetries,
Workers: defaultWorkers,
}
func loadConfig(path string) *Config {
if fileExists(path) {
buffer, err := ioutil.ReadFile(path)
check(err)
json.Unmarshal(buffer, &config)
} else {
fmt.Println("Using default configuration")
}
return &config
}