我想获取多个密钥上的数据,我该怎么做呢?目前我只得到了第一次调用的数据,其他的都被忽略了。
示例:
// Get config
consulKey = "postgres"
err := viper.AddRemoteProvider("consul", viper.GetString("CONSUL_ADDRESS_PORT"), consulKey)
// if errr != nil...
viper.SetConfigType("json")
err = viper.ReadRemoteConfig()
// if errr != nil...
viper.Get("addr") // => postgres:5432
// Get config
consulKey = "redis"
err := viper.AddRemoteProvider("consul", viper.GetString("CONSUL_ADDRESS_PORT"), consulKey)
// if errr != nil...
viper.SetConfigType("json")
err = viper.ReadRemoteConfig()
// if errr != nil...
viper.Get("addr") // => postgres:5432 ???
发布于 2020-12-08 23:12:21
使用conf := viper.New()
解决了我的问题。
https://stackoverflow.com/questions/65200841
复制相似问题