[英]GoLang change the value of a config item with viper
I have a yaml config file which has all the settings for my program. 我有一个yaml配置文件,其中包含程序的所有设置。 For example:
例如:
something:
enabled: true
I am using https://github.com/spf13/viper to get the value of an item: 我正在使用https://github.com/spf13/viper来获取项目的值:
viper.GetBool("something.enabled")
But I was wondering if there is a way to directly change the value of "something.enabled" to "false" using viper? 但是我想知道是否有办法使用毒蛇将“ something.enabled”的值直接更改为“ false”? The changes will apply on the config file as well so it will become:
所做的更改也将应用于配置文件,因此它将变为:
something:
enabled: false
It looks like you can just use the Set method, like this: 看起来您可以只使用Set方法,如下所示:
viper.Set("something.enabled", false) viper.Set(“ something.enabled”,false)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.