Created
September 9, 2019 10:01
-
-
Save BNPrashanth/7ff846fb52d35f985ad04435e8cd9e11 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package configs | |
import ( | |
"fmt" | |
"github.com/spf13/viper" | |
) | |
/* | |
InitializeViper Function initializes viper to read config.yml file and environment variables in the application. | |
*/ | |
func InitializeViper() { | |
// Set the file name of the configurations file | |
viper.SetConfigName("config") | |
// Set the path to look for the configurations file | |
viper.AddConfigPath(".") | |
// Enable VIPER to read Environment Variables | |
viper.AutomaticEnv() | |
viper.SetConfigType("yml") | |
if err := viper.ReadInConfig(); err != nil { | |
fmt.Printf("Error reading config file, %s", err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment