一款不错的golang配置文件库

先献上github地址 https://github.com/spf13/viper

什么是viper,为什么选用viper,让我们看看官方的说法

 

大概意思就是viper 兼容多种格式的配置文件,使用简单

 

 既然如此。那我们学习一下viper的使用

第一步

  安装 go get github.com/spf13/viper

第二步

  准备一个配置文件。这里使用yaml文件,不会操作的小伙伴可以 猛戳这里 参考教程

第三步

 

 

 就这样一个简单快捷的配置文件读取就写完啦

原文地址:https://www.cnblogs.com/Rxtong/p/13820211.html