我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

GoLang使用Viper更改配置项的值

I have a yaml config file which has all the settings for my program. For example:

something:
    enabled: true

I am using https://github.com/spf13/viper to get the value of an item:

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? 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:

viper.Set("something.enabled", false)

近期文章

  • Beego / Golang-查询要构造的值
  • 如何使Golint在VS Code上按类型而不是保存方式运行?
  • 如何使原始unicode编码的内容可读?
  • 使用sftp <<通过golang os / exec输入
  • 大猩猩mux http包
  • 如何在golang中以UTF-8编码gob?
  • 确认Go中的结构字段非零
  • GoLang二叉树-使用界面和结构
  • 如何使用REST API登录到IBM Bluemix?
  • Go服务器的无缝补丁部署,无需重启
  • 最初未知时在neo4j中建模关系
  • 如何从xml的根元素获取第一级注释
  • 在beantalkd中如何使用回调?
  • 二进制文件和其他文件
  • 在Go中使用pagetoken遍历Google Places API的麻烦
  • 如何在golang中将地图正确解压缩到自定义嵌套结构中(aws sdk-for-go)
  • 将所有项目都放在一个GOPATH工作区中有什么意义?
  • Golang重复Rails Devise gem密码加密
  • 在Windows上为Linux运行已编译的代码
  • 在reflect.MakeFunc中返回错误值

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华