feat: 配置 golangci-lint 静态分析并修复存量违规
- 新增 backend/.golangci.yml 配置 12 个 linter(forbidigo、errorlint、errcheck、staticcheck、revive、gocritic、gosec、bodyclose、noctx、nilerr、goimports、gocyclo) - 新增 lefthook.yml 配置 pre-commit hook 自动运行 lint - 修复存量代码违规:errors.Is/As 替换、zap.Error 替换、import 排序、errcheck 修复 - 更新 README 补充编码规范说明 - 归档 backend-code-lint 变更
This commit is contained in:
@@ -104,7 +104,8 @@ func TestPredefinedErrors(t *testing.T) {
|
||||
|
||||
func TestAsAppError(t *testing.T) {
|
||||
t.Run("nil输入", func(t *testing.T) {
|
||||
_, ok := AsAppError(nil)
|
||||
appErr, ok := AsAppError(nil)
|
||||
assert.Nil(t, appErr)
|
||||
assert.False(t, ok)
|
||||
})
|
||||
|
||||
@@ -122,7 +123,8 @@ func TestAsAppError(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("非AppError类型", func(t *testing.T) {
|
||||
_, ok := AsAppError(errors.New("普通错误"))
|
||||
appErr, ok := AsAppError(errors.New("普通错误"))
|
||||
assert.Nil(t, appErr)
|
||||
assert.False(t, ok)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user