From 75bd5d726e20e31c65bb835ad0d5c8d7fe5885b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=96=87=E5=B3=B0?= Date: Thu, 28 May 2026 14:47:59 +0800 Subject: [PATCH] up --- config/config.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/config/config.go b/config/config.go index de4ac21..a8f4854 100644 --- a/config/config.go +++ b/config/config.go @@ -87,12 +87,13 @@ func defaultConfig() *Config { // configPath 返回当前平台的配置文件路径 func configPath() string { if runtime.GOOS == "windows" { - // Windows: 相对于可执行文件的 conf/config.toml - exePath, err := os.Executable() + // Windows: 相对于工作目录的 conf/config.toml + // 注意: 使用工作目录而非 os.Executable(),因为 go run 时 exe 在临时目录 + wd, err := os.Getwd() if err != nil { return "conf/config.toml" } - return filepath.Join(filepath.Dir(exePath), "conf", "config.toml") + return filepath.Join(wd, "conf", "config.toml") } // Linux: FHS 标准 /etc/portal_page/config.toml return "/etc/portal_page/config.toml"