fix: 显式忽略不需要处理的错误返回值
对 os.Remove、conn.Close 等清理操作的返回值使用 _ 忽略, 避免 errcheck 静态检查告警。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
0de153bb24
commit
1e38fe9e90
12
internal/cache/disk_cache.go
vendored
12
internal/cache/disk_cache.go
vendored
@ -370,7 +370,7 @@ func (dc *DiskCache) Set(hashKey uint64, origKey string, data []byte, headers ma
|
||||
return
|
||||
}
|
||||
if err := os.Rename(tmpDataPath, dataPath); err != nil {
|
||||
os.Remove(tmpDataPath)
|
||||
_ = os.Remove(tmpDataPath)
|
||||
return
|
||||
}
|
||||
|
||||
@ -384,7 +384,7 @@ func (dc *DiskCache) Set(hashKey uint64, origKey string, data []byte, headers ma
|
||||
return
|
||||
}
|
||||
if err := os.Rename(tmpMetaPath, metaPath); err != nil {
|
||||
os.Remove(tmpMetaPath)
|
||||
_ = os.Remove(tmpMetaPath)
|
||||
return
|
||||
}
|
||||
|
||||
@ -424,8 +424,8 @@ func (dc *DiskCache) Delete(hashKey uint64) error {
|
||||
// 删除文件
|
||||
dataPath := dc.filePathFromHash(hashKey, "data")
|
||||
metaPath := dc.filePathFromHash(hashKey, "meta")
|
||||
os.Remove(dataPath)
|
||||
os.Remove(metaPath)
|
||||
_ = os.Remove(dataPath)
|
||||
_ = os.Remove(metaPath)
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -505,7 +505,7 @@ func (dc *DiskCache) evict() {
|
||||
// 删除文件
|
||||
dataPath := dc.filePathFromHash(oldestKey, "data")
|
||||
metaPath := dc.filePathFromHash(oldestKey, "meta")
|
||||
os.Remove(dataPath)
|
||||
os.Remove(metaPath)
|
||||
_ = os.Remove(dataPath)
|
||||
_ = os.Remove(metaPath)
|
||||
}
|
||||
}
|
||||
|
||||
@ -429,7 +429,7 @@ func (s *TCPSocket) Close() error {
|
||||
|
||||
// 关闭连接
|
||||
if s.conn != nil {
|
||||
s.conn.Close()
|
||||
_ = s.conn.Close()
|
||||
s.conn = nil
|
||||
}
|
||||
|
||||
@ -802,7 +802,7 @@ func tcpSocketSetTimeouts(L *glua.LState) int {
|
||||
// tcpSocketGC __gc 元方法
|
||||
func tcpSocketGC(L *glua.LState) int {
|
||||
socket := checkTCPSocket(L, 1)
|
||||
socket.Close()
|
||||
_ = socket.Close()
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
@ -82,7 +82,7 @@ func NewGeoIPLookup(dbPath string, cacheSize int, ttl time.Duration, privateIPBe
|
||||
cache, err := lru.New[string, *cachedCountry](cacheSize)
|
||||
if err != nil {
|
||||
|
||||
db.Close()
|
||||
_ = db.Close()
|
||||
return nil, fmt.Errorf("create lru cache: %w", err)
|
||||
}
|
||||
|
||||
|
||||
@ -534,7 +534,7 @@ func (s *Server) createListener(cfg *config.ServerConfig) (net.Listener, error)
|
||||
|
||||
// 2. 清理旧 socket 文件
|
||||
if _, err := os.Stat(socketPath); err == nil {
|
||||
os.Remove(socketPath)
|
||||
_ = os.Remove(socketPath)
|
||||
}
|
||||
|
||||
// 3. 创建 Unix socket listener
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user