2020
12-17
12-17
Golang使用第三方包viper读取yaml配置信息操作
Golang有很多第三方包,其中的viper支持读取多种配置文件信息。本文只是做一个小小demo,用来学习入门用的。1、安装gogetgithub.com/spf13/viper2、编写一个yaml的配置文件,config.yamldatabase:host:127.0.0.1user:rootdbname:testpwd:1234563、编写学习脚本main.go,读取config.yaml配置信息packagemainimport("fmt""os""github.com/spf13/viper")funcmain(){//获取项目的执行路径path,err:=os.Getw...
继续阅读 >