You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I'm writing a cli application with cobra and viper. A problem I'm running into is that if I save the viper config to a config file, it saves the default values I set (which means I can't change the default with an update) as well as things like env vars which imo should be temporary. I'd like to only save values set through code or in the config file
So far it seems I would need to do some legwork and write some custom code to handle that, thankfully viper.InConfig exists, but not something like viper.IsDefault. I could just check if the value is the same as my default but that's also leg work and wouldn't work with setting a key to be explicitly the same value as the default one
Anyway, is there an easy way to do this or to solve this issue? Thanks!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi! I'm writing a cli application with cobra and viper. A problem I'm running into is that if I save the viper config to a config file, it saves the default values I set (which means I can't change the default with an update) as well as things like env vars which imo should be temporary. I'd like to only save values set through code or in the config file
So far it seems I would need to do some legwork and write some custom code to handle that, thankfully
viper.InConfig
exists, but not something likeviper.IsDefault
. I could just check if the value is the same as my default but that's also leg work and wouldn't work with setting a key to be explicitly the same value as the default oneAnyway, is there an easy way to do this or to solve this issue? Thanks!
Beta Was this translation helpful? Give feedback.
All reactions