From d237d21881170162813bc7e99be235a720933f5b Mon Sep 17 00:00:00 2001 From: xc Date: Tue, 2 Sep 2025 10:02:48 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=87=BD=E6=95=B0=E6=89=80?= =?UTF-8?q?=E5=9C=A8=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scagent/config/config.go | 23 ----------------------- scagent/util/fsutil.go | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/scagent/config/config.go b/scagent/config/config.go index c928b14..90b42f6 100644 --- a/scagent/config/config.go +++ b/scagent/config/config.go @@ -3,10 +3,6 @@ package config import ( "fmt" "net" - "scagnet/util" - - "go.uber.org/zap" - "gopkg.in/ini.v1" ) type Config struct { @@ -51,22 +47,3 @@ func GetLocalIP() (string, error) { } } - -// 读取配置文件 -func ReadConfig() { - logger := util.NewProductionLogger() - defer logger.Sync() - // 加载文件 - cfg, err := ini.Load("app.conf") - if err != nil { - logger.Error("读取配置文件失败", zap.Error(err)) - return - } - // - iport, err := cfg.Section("rpc").Key("port").Int() - if err != nil { - logger.Error("读取配置文件失败", zap.Error(err)) - return - } - G.Port = fmt.Sprintf("%d", iport) -} diff --git a/scagent/util/fsutil.go b/scagent/util/fsutil.go index c1b5c3d..f170f8b 100644 --- a/scagent/util/fsutil.go +++ b/scagent/util/fsutil.go @@ -16,6 +16,8 @@ import ( "strings" "github.com/schollz/progressbar/v3" + "go.uber.org/zap" + "gopkg.in/ini.v1" ) // 遍历目录下的文件 @@ -389,3 +391,22 @@ func CompressToZip(dest string, currentPath string, paths []string) error { os.Rename(dest, path.Join("./sync_zips/", dest)) return nil } + +// 读取配置文件 +func ReadConfig() { + logger := NewProductionLogger() + defer logger.Sync() + // 加载文件 + cfg, err := ini.Load("app.conf") + if err != nil { + logger.Error("读取配置文件失败", zap.Error(err)) + return + } + // + iport, err := cfg.Section("rpc").Key("port").Int() + if err != nil { + logger.Error("读取配置文件失败", zap.Error(err)) + return + } + config.G.Port = fmt.Sprintf("%d", iport) +}