From 46ae18ce307208e9ca80aa1477d3b680e3935c20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=AD=90=E6=97=BA?= <15039612+liu-ziwang123@user.noreply.gitee.com> Date: Mon, 4 Nov 2024 09:18:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:GetSalt=E5=87=BD=E6=95=B0=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E6=96=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- godo/files/os.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/godo/files/os.go b/godo/files/os.go index 0ca7e2b..8f6f7de 100644 --- a/godo/files/os.go +++ b/godo/files/os.go @@ -364,7 +364,11 @@ func IsHavePwd(pwd string) bool { func GetSalt(r *http.Request) (string, error) { data, ishas := libs.GetConfig("salt") if ishas { - return data.(string), nil + // 断言成功则返回 + if salt, ok := data.(string); ok { + return salt, nil + } + return "", fmt.Errorf("类型断言失败,期望类型为 string") } salt := r.Header.Get("salt") if salt != "" {