viper的源码地址https://github.com/spf13/viper,它是一个可以用来读取配置文件的工具。在项目中可以通过下面指令安装:
viper
https://github.com/spf13/viper
go get github.com/spf13/viper
下面我们通过两个例子,来介绍一下viper在项目中应该如何使用。
首先,在项目的路劲下面新建一个文件config.yaml,并在文件中添加下面的内容:
config.yaml
name: "zhangsan" port: 9527
上一篇:AM5728(AM5708)开发实战之移植OpenCV-3.4.11
下一篇:MySQL(二)视图、锁、存储过程、触发器、锁以及常用工具