kelseyhightower / envconfig

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

Optional check for mispelled/unknown env vars #105

Closed CAFxX closed 6 years ago

CAFxX commented 6 years ago

It would be useful to prevent silent misconfigurations to have envconfig optionally be able to check if any of the environment variables currently set match the application prefix but is not in the set of allowed variable names.

type config struct {
  a int
  b int `ignored:"true"`
}

assuming the application prefix is MYAPP, the optional check should return the corresponding error if supplied with each env var:

MYAPP_A=1 # no error
MYAPP_B=1 # error: attempting to set ignored variable MYAPP_B
MYAPP_C=1 # error: attempting to set unknown variable MYAPP_C