From 48307d640f739c55c07ee95e3898348159dd750b Mon Sep 17 00:00:00 2001 From: Fabian Knorr Date: Mon, 5 Feb 2018 21:49:41 +0100 Subject: [PATCH 1/5] 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 { From e867180379fb2db97eb085418064d9ab6bdf4403 Mon Sep 17 00:00:00 2001 From: Fabian Knorr Date: Tue, 6 Feb 2018 20:14:04 +0100 Subject: [PATCH 2/5] Simplifed function GetConfigFilePath() --- viper.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/viper.go b/viper.go index 89e3326..78cd1e3 100644 --- a/viper.go +++ b/viper.go @@ -1734,13 +1734,12 @@ func (v *Viper) getConfigFile() (string, error) { return v.getConfigFile() } -func GetConfigFilePath() (string, error) { +func GetConfigFilePath() { // 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 + return v.getConfigFile() } func (v *Viper) searchInPath(in string) (filename string) { From b6a7a50b2f4d34b552c701d4a71d4d95f85da7d1 Mon Sep 17 00:00:00 2001 From: Fabian Knorr Date: Tue, 6 Feb 2018 20:15:27 +0100 Subject: [PATCH 3/5] Doc for GetConfigFilePath() now precedes the function --- viper.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/viper.go b/viper.go index 78cd1e3..8ea7c86 100644 --- a/viper.go +++ b/viper.go @@ -1734,11 +1734,11 @@ func (v *Viper) getConfigFile() (string, error) { return v.getConfigFile() } +// 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. func GetConfigFilePath() { - // 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. return v.getConfigFile() } From e252e1cc54ad5b64a9ea72731ac10c9b51c9b718 Mon Sep 17 00:00:00 2001 From: Fabian Knorr Date: Sat, 10 Feb 2018 16:03:06 +0100 Subject: [PATCH 4/5] Bugfix: simplifying GetConfigFilePath() led to compile error --- viper.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/viper.go b/viper.go index 8ea7c86..1dee019 100644 --- a/viper.go +++ b/viper.go @@ -1738,7 +1738,7 @@ func (v *Viper) getConfigFile() (string, error) { // // Useful when you want to write the configPath to logfiles, stdout, etc. // Comes in handy during debugging or when running in production environments. -func GetConfigFilePath() { +func GetConfigFilePath() (string, error) { return v.getConfigFile() } From 0a8c192870901e7602b412a97ab154d26f234a8f Mon Sep 17 00:00:00 2001 From: Fabian Knorr Date: Tue, 27 Feb 2018 21:24:08 +0100 Subject: [PATCH 5/5] Update Godoc for function GetConfigFilePath to meet Godocs approach to documentation --- viper.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/viper.go b/viper.go index 1dee019..1fe532f 100644 --- a/viper.go +++ b/viper.go @@ -1734,10 +1734,7 @@ func (v *Viper) getConfigFile() (string, error) { return v.getConfigFile() } -// 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. +// GetConfigFilePath returns the path where Viper actually found the configfile it uses. func GetConfigFilePath() (string, error) { return v.getConfigFile() }