配置

yago 模版生成的项目默认采用 toml 格式的配置文件,配置文件在程序启动后便开始解析,解析完成后存储在全局 yago.Config 中,yago.Config 是 viper 的扩展,原生采用 viper 的方法来获取配置文件的值即可。

example:

// 字符串
confString := yago.Config.GetString("conf_string")
// 整数
confInt := yago.Config.GetInt("conf_int")
// 浮点数
confFloat64 := yago.Config.GetFloat64("conf_float64")
// 持续时间
confDuration := yago.Config.GetDuration("conf_duration")

results matching ""

    No results matching ""