From 96b2599ee2819b6d1a999d77eeb1fc27c1b07188 Mon Sep 17 00:00:00 2001 From: Chris Doherty Date: Thu, 15 Oct 2020 08:39:54 -0600 Subject: [PATCH] Add env prefix accessor method --- viper.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/viper.go b/viper.go index 7027715..704a0cf 100644 --- a/viper.go +++ b/viper.go @@ -428,6 +428,15 @@ func (v *Viper) SetEnvPrefix(in string) { } } +// EnvPrefix returns the ENV prefix set with SetEnvPrefix for the global +// Viper instance. +func EnvPrefix() string { return v.envPrefix } + +// EnvPrefix returns the env prefix set with SetEnvPrefix. +func (v *Viper) EnvPrefix() string { + return v.envPrefix +} + func (v *Viper) mergeWithEnvPrefix(in string) string { if v.envPrefix != "" { return strings.ToUpper(v.envPrefix + "_" + in)