fix: mysql密码中有特殊字符导致拼接的MysqlDns错误

This commit is contained in:
TBXark
2023-05-22 14:26:23 +08:00
parent 0c4249634c
commit 2b805ff770
+3 -2
View File
@@ -3,6 +3,7 @@ package config
import (
"fmt"
"github.com/spf13/viper"
"net/url"
"os"
"time"
)
@@ -41,8 +42,8 @@ func Init() {
RuntimePath,
viper.GetString("log_save_path"))
MysqlDns = fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=True&loc=Local",
viper.GetString("mysql_user"),
viper.GetString("mysql_passwd"),
url.QueryEscape(viper.GetString("mysql_user")),
url.QueryEscape(viper.GetString("mysql_passwd")),
fmt.Sprintf(
"%s:%s",
viper.GetString("mysql_host"),