From f427f04d351a7c18772daaa4b3c76d7dd9d28e1d Mon Sep 17 00:00:00 2001 From: ZacharyZcR <2903735704@qq.com> Date: Mon, 18 May 2026 05:08:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DSA1006:=20fmt.Errorf(i18n.Tr)?= =?UTF-8?q?=E6=94=B9=E7=94=A8fmt.Errorf("%s",=20...)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/flag.go | 2 +- common/initialize.go | 2 +- common/network.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/flag.go b/common/flag.go index 23fbe96..70192a4 100644 --- a/common/flag.go +++ b/common/flag.go @@ -310,7 +310,7 @@ func checkParameterConflicts() error { invalidChars := []string{",", ";", " ", "|", "&"} for _, char := range invalidChars { if strings.Contains(fv.LocalPlugin, char) { - return fmt.Errorf(i18n.Tr("param_local_multi_plugin", char)) + return fmt.Errorf("%s", i18n.Tr("param_local_multi_plugin", char)) } } } diff --git a/common/initialize.go b/common/initialize.go index 44b96a5..ce5431a 100644 --- a/common/initialize.go +++ b/common/initialize.go @@ -82,7 +82,7 @@ func ValidateExclusiveParams(info *HostInfo) error { } if paramCount > 1 { - return fmt.Errorf(i18n.Tr("param_exclusive", activeParam)) + return fmt.Errorf("%s", i18n.Tr("param_exclusive", activeParam)) } return nil diff --git a/common/network.go b/common/network.go index 0973828..ad61098 100644 --- a/common/network.go +++ b/common/network.go @@ -110,7 +110,7 @@ func WrapperTcpWithTimeout(network, address string, timeout time.Duration) (net. // 检查发包限制 - 在代理连接前进行控制 if canSend, reason := CanSendPacket(); !canSend { LogError(fmt.Sprintf("TCP连接 %s 受限: %s", address, reason)) - return nil, fmt.Errorf(i18n.Tr("network_rate_limited", reason)) + return nil, fmt.Errorf("%s", i18n.Tr("network_rate_limited", reason)) } // 获取全局拨号器(复用,避免重复创建) @@ -167,7 +167,7 @@ func SafeHTTPDo(client *http.Client, req *http.Request) (*http.Response, error) // 检查发包限制 if canSend, reason := CanSendPacket(); !canSend { LogError(fmt.Sprintf("HTTP请求 %s 受限: %s", req.URL.String(), reason)) - return nil, fmt.Errorf(i18n.Tr("network_rate_limited", reason)) + return nil, fmt.Errorf("%s", i18n.Tr("network_rate_limited", reason)) } // 执行HTTP请求