From 2af0c329c551386c451c33b79786deb6364afb75 Mon Sep 17 00:00:00 2001 From: ZacharyZcR Date: Wed, 13 May 2026 02:37:53 +0800 Subject: [PATCH] fix: resolve golangci-lint errcheck and staticcheck warnings --- common/dns_cache.go | 3 ++- plugins/local/avdetect.go | 2 +- plugins/local/cleaner.go | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/common/dns_cache.go b/common/dns_cache.go index bb91b84..b12f514 100644 --- a/common/dns_cache.go +++ b/common/dns_cache.go @@ -16,7 +16,8 @@ type dnsCache struct { // ResolveIP 解析 host 为 *net.IPAddr,结果缓存 func (c *dnsCache) ResolveIP(host string) (*net.IPAddr, error) { if v, ok := c.m.Load(host); ok { - return v.(*net.IPAddr), nil + addr, _ := v.(*net.IPAddr) + return addr, nil } addr, err := net.ResolveIPAddr("ip", host) if err != nil { diff --git a/plugins/local/avdetect.go b/plugins/local/avdetect.go index f2da559..b1436db 100644 --- a/plugins/local/avdetect.go +++ b/plugins/local/avdetect.go @@ -107,7 +107,7 @@ func (p *AVDetectPlugin) Scan(ctx context.Context, info *common.HostInfo, sessio // 统计结果 output.WriteString("=== 检测结果 ===\n") - output.WriteString(fmt.Sprintf("检测到的AV产品: %d个\n", len(detectedAVs))) + _, _ = fmt.Fprintf(&output, "检测到的AV产品: %d个\n", len(detectedAVs)) if len(detectedAVs) > 0 { output.WriteString("检测到的产品: " + strings.Join(detectedAVs, ", ") + "\n") diff --git a/plugins/local/cleaner.go b/plugins/local/cleaner.go index d843a97..5c2ddb6 100644 --- a/plugins/local/cleaner.go +++ b/plugins/local/cleaner.go @@ -44,7 +44,7 @@ func (p *CleanerPlugin) Scan(ctx context.Context, info *common.HostInfo, session for _, file := range files { if p.removeFile(file) { filesCleared++ - output.WriteString(fmt.Sprintf("清理文件: %s\n", file)) + _, _ = fmt.Fprintf(&output, "清理文件: %s\n", file) } } @@ -53,7 +53,7 @@ func (p *CleanerPlugin) Scan(ctx context.Context, info *common.HostInfo, session for _, file := range tempFiles { if p.removeFile(file) { filesCleared++ - output.WriteString(fmt.Sprintf("清理临时文件: %s\n", file)) + _, _ = fmt.Fprintf(&output, "清理临时文件: %s\n", file) } }