From f3d3930bb300840a7b032a89ccfdecc80ee5f708 Mon Sep 17 00:00:00 2001 From: zhangxin Date: Mon, 2 Aug 2021 17:40:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=BB=E5=8F=96=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E7=9A=84=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- infra/config/config.go | 5 ++--- infra/logger/config.go | 7 ++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/infra/config/config.go b/infra/config/config.go index f3e1ba0..c48ee74 100644 --- a/infra/config/config.go +++ b/infra/config/config.go @@ -3,7 +3,6 @@ package config import ( "LAPP_ETL/utils" "github.com/spf13/viper" - "path" ) var AppConfig Config @@ -48,13 +47,13 @@ type ETCD struct { } func InitConfig() (err error) { - baseDir, err := utils.GetCurrentPath("/conf") + baseDir, err := utils.GetCurrentPath("conf") if err != nil { return } viper.SetConfigName("app_config") viper.SetConfigType("yaml") - viper.AddConfigPath(path.Join(baseDir, "../conf/")) + viper.AddConfigPath(baseDir) if err = viper.ReadInConfig(); err != nil { return } diff --git a/infra/logger/config.go b/infra/logger/config.go index 8b5da20..d43dd52 100644 --- a/infra/logger/config.go +++ b/infra/logger/config.go @@ -1,6 +1,7 @@ package logger import ( + "LAPP_ETL/utils" "errors" "github.com/spf13/viper" ) @@ -48,9 +49,13 @@ type outputSettings struct { func InitConfig() error { var err error + baseDir, err := utils.GetCurrentPath("conf") + if err != nil { + return err + } viper.SetConfigName("log_config") viper.SetConfigType("yaml") - viper.AddConfigPath("./conf/") + viper.AddConfigPath(baseDir) if err = viper.ReadInConfig(); err != nil { return err }