kelseyhightower / envconfig

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

support optional trim #195

Open fernandodr19 opened 3 years ago

fernandodr19 commented 3 years ago

I've ran into an issue recently where a subtle new line character was incorrectly added by the devops team at the end of a password in a config file, which led to an error in authentication. This took me quite some time to figure out as we were moving into new servers with new credentials and the env output was rather subtle as I didn't really expect this to be an issue.

As these secrets are handled by different teams, I cannot be sure that this won't happen again and would like to defend against it. This could easily be avoided if we had an option to trim variables, for example. I was thinking of something like

type config struct {
    MyPass string `envconfig:"MY_PASS" trim:"true"`
}

Or something along those lines. What do you guys think?