diff --git a/confighelper/configHelper.go b/confighelper/configHelper.go index 49ca2e2ef41a265e63fb80d33d0104fdeef526fc..ca62037cc7ed2ab68c443cc6f9a5a1202fa2d799 100644 --- a/confighelper/configHelper.go +++ b/confighelper/configHelper.go @@ -1,21 +1,24 @@ package confighelper +import ( + "fmt" + + "github.com/spf13/viper" +) + //InitViper function to initialize viper func InitViper() { - // viper.SetConfigName("config") // name of config file (without extension) - // viper.AddConfigPath(".") // optionally look for config in the working directory - // err := viper.ReadInConfig() - // // Find and read the config file - // if err != nil { // Handle errors reading the config file - // panic(fmt.Errorf("Fatal error config file %s ", err)) - // } + viper.SetConfigName("config") // name of config file (without extension) + viper.AddConfigPath(".") // optionally look for config in the working directory + err := viper.ReadInConfig() + // Find and read the config file + if err != nil { // Handle errors reading the config file + panic(fmt.Errorf("Fatal error config file %s ", err)) + } } //GetConfig method to get configs from config file func GetConfig(keyName string) string { - - // keyValue := viper.GetString(keyName) - - // return keyValue - return "" + keyValue := viper.GetString(keyName) + return keyValue }