You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use Viper to read a configuration file called .env, which is located in the directory /var/www/config/. I have tried two approaches, but both of them resulted in errors.
viper.setConfigFile(".env")
viper.AddConfigPath("/var/www/config/")
// panic: open .env: no such file or directory
viper.SetConfigName("")
viper.SetConfigType("env")
viper.AddConfigPath("/var/www/config/")
// panic: Config File "config" Not Found in "[/var/www/config]"
I have found that using viper.SetConfigFile("/var/www/config/.env") works, but I'm looking for a solution that using AddConfigPath, as there may be multiple config paths (on different server).
Is there a way to read the .env file without specifying the filename and support search in multiple config path?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm trying to use Viper to read a configuration file called .env, which is located in the directory /var/www/config/. I have tried two approaches, but both of them resulted in errors.
I have found that using
viper.SetConfigFile("/var/www/config/.env")
works, but I'm looking for a solution that using AddConfigPath, as there may be multiple config paths (on different server).Is there a way to read the .env file without specifying the filename and support search in multiple config path?
Beta Was this translation helpful? Give feedback.
All reactions