ci(lint): golangci-lint v2 入门禁并归零
- .golangci.yml:standard 集 - errcheck(存量 38 处裸忽略待专项),staticcheck 关纯风格/quickfix - 清理 3 个无引用死函数;SanitizedJSON 不可达分支收敛为接口分支 + nil 指针防护(原死分支中的 nil 检查从未执行) - CI backend job 增加 golangci-lint-action@v6
This commit is contained in:
1 parent
a69142fbfe
commit
c33ea9d0a8
5 files changed
+20
-58
No files matched your search
@@ -3,7 +3,6 @@ package services
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -264,23 +263,6 @@ func DecryptCred(encrypted string) (string, error) {
|
||||
// ==================== 通用工具函数 ====================
|
||||
|
||||
// writeTempFile 安全地创建临时文件,返回文件路径和清理函数
|
||||
func writeTempFile(pattern, content string, perm os.FileMode) (string, func(), error) {
|
||||
f, err := os.CreateTemp("", pattern)
|
||||
if err != nil {
|
||||
return "", nil, fmt.Errorf("create temp file failed: %w", err)
|
||||
}
|
||||
if _, err := f.WriteString(content); err != nil {
|
||||
f.Close()
|
||||
os.Remove(f.Name())
|
||||
return "", nil, fmt.Errorf("write temp file failed: %w", err)
|
||||
}
|
||||
f.Close()
|
||||
if perm > 0 {
|
||||
os.Chmod(f.Name(), perm)
|
||||
}
|
||||
cleanup := func() { os.Remove(f.Name()) }
|
||||
return f.Name(), cleanup, nil
|
||||
}
|
||||
|
||||
// indentYAML 对 YAML 内容进行缩进(用于嵌入 ConfigMap)
|
||||
func indentYAML(s string, spaces int) string {
|
||||
|
||||
Reference in new issue
Block a user