From 48307d640f739c55c07ee95e3898348159dd750b Mon Sep 17 00:00:00 2001 From: Fabian Knorr Date: Mon, 5 Feb 2018 21:49:41 +0100 Subject: [PATCH] New func GetConfigFilePath() which returns the path where Viper actually found the logfile --- viper.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/viper.go b/viper.go index ad8a037..89e3326 100644 --- a/viper.go +++ b/viper.go @@ -1734,6 +1734,15 @@ func (v *Viper) getConfigFile() (string, error) { return v.getConfigFile() } +func GetConfigFilePath() (string, error) { + // Returns the path where Viper actually found the logfile it uses. + // + // Useful when you want to write the configPath to logfiles, stdout, etc. + // Comes in handy during debugging or when running in production environments. + cf, err := v.getConfigFile() + return cf, err +} + func (v *Viper) searchInPath(in string) (filename string) { jww.DEBUG.Println("Searching for config in ", in) for _, ext := range SupportedExts {