Last active
May 15, 2021 18:55
-
-
Save madflojo/7dd72ce95cac7b14280f1f799463364f to your computer and use it in GitHub Desktop.
Viper Article - Adding Files
This file contains hidden or 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
// Load Config | |
cfg.AddConfigPath("./conf") | |
cfg.SetEnvPrefix("app") | |
cfg.AllowEmptyEnv(true) | |
cfg.AutomaticEnv() | |
err := cfg.ReadInConfig() | |
if err != nil { | |
switch err.(type) { | |
case viper.ConfigFileNotFoundError: | |
log.Warnf("No Config file found, loaded config from Environment - Default path ./conf") | |
default: | |
log.Fatalf("Error when Fetching Configuration - %s", err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment