conf.go 651 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
package conf

import (
	"errors"
	"github.com/spf13/viper"
)

func ReadConfig(filename string) error {

10
	viper.SetConfigFile(filename)
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
	err := viper.ReadInConfig()
	if err != nil {
		return errors.New(err.Error() + ("Fatal error in config file."))
	}
	return nil
}

func GetStringValue(key string) string {
	return viper.GetString(key)
}

func GetBoolValue(key string) bool {
	return viper.GetBool(key)
}

func GetIntValue(key string) int {
	return viper.GetInt(key)
}

func GetStringArrayValue(key string) []string {
	return viper.GetStringSlice(key)
}

func GetStringMapString(key string) map[string]string {
	return viper.GetStringMapString(key)
}