2 ms·
Environment variables are awful for config. You get no validation at all - typo in your variable name? It'll just silently ignore it. They can be injected by an
by IshKebab 3y ago
Environment variables are awful for config. You get no validation at all - typo in your variable name? It'll just silently ignore it. They can be injected by any parent process and are invisible to all child processes. Also they can be accessed by a simple getenv() anywhere in the program which eventually leads to your config being undocumented and spread all through your code.
Environment variables are generally a hack and should be avoided where possible.
- omginternets 3y agoI use https://pkg.go.dev/github.com/urfave/cli/v3 https://pkg.go.dev/github.com/urfave/cli/v3 in my Go programs, and it does enough validation that this has never been a problem in practice, especially when paired with a simple config scheme (see my other comment).