Revert "refactor(app/user): 重构配置文件读取逻辑并移除未使用的依赖"

This reverts commit cedec8b669a814b75f930c04412b9ce328a0eb9d.
This commit is contained in:
suyiiyii 2025-01-21 23:25:49 +08:00
parent cedec8b669
commit 2c85024a08
Signed by: suyiiyii
GPG Key ID: 044704CB29B8AD85
3 changed files with 7 additions and 5 deletions

View File

@ -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")

View File

@ -6,6 +6,7 @@ replace github.com/apache/thrift => github.com/apache/thrift v0.13.0
require (
github.com/cloudwego/kitex v0.12.1
github.com/joho/godotenv v1.5.1
github.com/kitex-contrib/obs-opentelemetry/logging/logrus v0.0.0-20241120035129-55da83caab1b
github.com/kitex-contrib/registry-consul v0.0.0-20240508100819-2905e45155c1
github.com/kr/pretty v0.3.1

View File

@ -320,6 +320,8 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=