kelseyhightower / envconfig

Golang library for managing configuration data from environment variables
MIT License
5.02k stars 377 forks source link

Required tag complains when root environment variable exists #88

Closed veqryn closed 7 years ago

veqryn commented 7 years ago

I was expecting the below to succeed, since ENV is set. However, the error I get says that MYAPP_ENV must exist. Perhaps we need a required_any:"true" tag? I may be able to make a PR, but I want to know what you think first?

export ENV="dev"
export MYAPP_STUFF="stuff"
type AllEnv struct {
    Env    string  `required:"true"`
    Stuff  string  `required:"true"`
}

func TestNewEnvVars(t *testing.T) {
    var env AllEnv
    envconfig.MustProcess("MYAPP", &env)
}
veqryn commented 7 years ago

Nevermind, I didn't realize I needed the envconvig tag.