I was trying to isolate the development config file from production config by setting a environment variable. Operating System: MAC OS
, I set a environment variable DEBUG = true
through .bash_profile
by adding export DEBUG = True
. echo $debug
gets correct value true
. I wrote a function using viper
which fetches the value of "debug". But print nil. Where part is wrong?
func GetEnvInfo(env string) string {
viper.AutomaticEnv()
v := viper.Get(env)
return v
}
func main() {
env := GetEnvInfo("debug")
fmt.Println(env)
}