From 1fae74191eab39503990d933649b261cbadc50c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BB=9D=E5=B0=98?= <237809796@qq.com> Date: Wed, 16 Oct 2024 13:18:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E5=AF=86=E7=A0=81=E5=90=AB=E7=89=B9=E6=AE=8A=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E5=AF=BC=E8=87=B4=E7=9A=84=E8=A7=A3=E6=9E=90=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/config/config.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/internal/config/config.go b/internal/config/config.go index 15aa893..d88fc9c 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -3,7 +3,9 @@ package config import ( "github.com/spf13/viper" "log" + "net/url" "os" + "strings" ) type Log struct { @@ -77,6 +79,14 @@ func ReadConfig() Config { if err := viper.Unmarshal(&conf); err != nil { log.Fatalf("Failed to unmarshal config: %s", err.Error()) } + // conf.Ztimer.Db.Password 包含 %, 做url 转码 + if strings.Contains(conf.Ztimer.Db.Password, "%") { + unescape, err := url.QueryUnescape(conf.Ztimer.Db.Password) + if err == nil { + conf.Ztimer.Db.Password = unescape + } + } + return conf } // 如果在 /etc/ 目录和当前程序所在目录下均未找到配置文件,则报错