-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
46 lines (40 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
44
45
46
package config
import (
"fmt"
"github.com/spf13/viper"
)
// Create private data struct to hold config options.
type config struct {
Postgres struct {
Host string
Port string
Database string
User string
Password string
}
Google_geocoding_api struct {
Api_key string
}
S3 struct {
Access_key string
Secret_key string
Bucket_name_banners string
}
}
// Read the config file from the current directory and marshal
// into the conf config struct.
func GetConf() *config {
viper.AddConfigPath(".")
viper.AddConfigPath("../../")
viper.SetConfigName("config")
err := viper.ReadInConfig()
if err != nil {
fmt.Printf("%v", err)
}
conf := &config{}
err = viper.Unmarshal(conf)
if err != nil {
fmt.Printf("unable to decode into config struct, %v", err)
}
return conf
}