Open Skarlso opened 2 years ago
To be fair, if the params and viper calls are leaving the cmd code, and leaking "throughout the codebase" we have other problems, that shouldn't happen either.
Can you link to a few examples?
So, now I understand that GetString is being used to it falls back to environment property in case the flag is not defined. However, the names should be a const so we don't mistype them and they are discoverable and don't have to copy paste them all over the codebase.
Examples are aplenty if you search for viper.GetString("
. :) It's mostly in helpers.go and server/cluster.go
which might in the process of being refactored?
These
viper.GetString
calls make flags brittle and things like these:Will make this struct flag:
Untraceable. One might think that this flag is not used, but the actual name of the flag can be found throughout the codebase for which the value is retrieved with GetString.
A better option is to pass around the actual Params and flags so we don't end up accidentally deleting a used flag. :)