config
config copied to clipboard
Add command line args processing
A concern I have is handling command line args. I personally have the pref to this order of precedence for configuration:
- config file
- can be overridden by env vars
- can be overwritten by command line args
Would it make sense to add a bit of code for this, or how would you propose to handle this use case?
I would propose to use separate tags, as normally not all config items should be configurable via command line and the arg names should be different.
https://pkg.go.dev/flag#pkg-overview
The stdlib can already bind pointers to flags, that’s handled every usecase I’ve need so far. It seems it also handles your usecases of
- not every config value exists in the command line
- the arg names can be different
I don’t want to dismiss your suggestion though - could you write some pseudocode showing what you would want?