-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
58 lines (49 loc) · 1.01 KB
/
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package govdev
import (
"log"
"github.com/spf13/viper"
)
type Config struct {
Port string
Debug bool
Hidebanner bool
Database DatabaseConfig
Cache CacheConfig
ObjectStore MinioConfig
}
type DatabaseConfig struct {
Engine string
User string
Password string
DBName string
Port string
SSLMode string
Host string
}
type CacheConfig struct {
Engine string
Host string
Port string
Password string
DBName int
}
type MinioConfig struct {
Host string
Port string
AccessKeyID string
SecretAccessKey string
UseSSL bool
}
func LoadConfig() (Config, []error) {
var errs []error
viper.SetConfigFile("config.yaml")
viper.AddConfigPath(".")
if err := viper.ReadInConfig(); err != nil {
log.Fatalf("Unable to find config file, error: %s\n", err.Error())
}
var conf Config
if err := viper.Unmarshal(&conf); err != nil {
log.Fatalf("Unable to unmarshal into struct, error: %s\n", err.Error())
}
return conf, errs
}