From a0cdead743e9d63810a2fabd801f42024a79554b Mon Sep 17 00:00:00 2001 From: RaviAnand Mohabir Date: Thu, 26 Oct 2023 22:40:49 +0200 Subject: [PATCH] feat: :sparkles: add /etc/ and $home config paths --- main.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 39626f1..35a49d1 100644 --- a/main.go +++ b/main.go @@ -9,10 +9,12 @@ import ( ) func main() { - viper.SetConfigName("config") // name of config file (without extension) - viper.SetConfigType("yaml") // REQUIRED if the config file does not have the extension in the name - viper.AddConfigPath(".") // optionally look for config in the working directory - viper.ReadInConfig() // Find and read the config file + viper.SetConfigName("config") // name of config file (without extension) + viper.SetConfigType("yaml") // REQUIRED if the config file does not have the extension in the name + viper.AddConfigPath("/etc/appname/") // path to look for the config file in + viper.AddConfigPath("$HOME/.appname") // call multiple times to add many search paths + viper.AddConfigPath(".") // optionally look for config in the working directory + viper.ReadInConfig() // Find and read the config file viper.SetDefault("server.scheme", "http") viper.SetDefault("server.host", "localhost:5001")