Revert "refactor(app/user): 重构配置文件读取逻辑并移除未使用的依赖"
This reverts commit cedec8b669.
This commit is contained in:
@@ -71,22 +71,21 @@ func initConf() {
|
||||
//if err != nil {
|
||||
// panic(err)
|
||||
//}
|
||||
fmt.Println("configFile", configFile)
|
||||
conf = new(Config)
|
||||
err := yaml.Unmarshal(configFile, conf)
|
||||
|
||||
// viper 获取远程配置测试
|
||||
err = viper.AddRemoteProvider("consul", conf.Registry.RegistryAddress[0], "USER")
|
||||
fmt.Println("registry", conf.Registry.RegistryAddress[0])
|
||||
fmt.Println("MYSQL_DSN", viper.GetString("MYSQL_DSN"))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return
|
||||
}
|
||||
viper.SetConfigType("yaml")
|
||||
err = viper.ReadRemoteConfig()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return
|
||||
}
|
||||
fmt.Println(conf.Registry.RegistryAddress[0])
|
||||
fmt.Println(viper.GetString("MYSQL_DSN"))
|
||||
|
||||
conf.MySQL.DSN = viper.GetString("MYSQL_DSN")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user