feat: null safety

This commit is contained in:
2024-12-29 16:35:38 +07:00
commit b32eafb43d
13 changed files with 249 additions and 0 deletions

18
common/unnamedChecks.go Normal file
View File

@@ -0,0 +1,18 @@
package common
import (
"go/ast"
"golang.org/x/tools/go/analysis"
)
func CheckUnnamedModel(pass analysis.Pass, typeSpec ast.TypeSpec) {
if typeSpec.Name == nil {
pass.Reportf(typeSpec.Pos(), "Unnamed model\n")
}
}
func CheckUnnamedField(pass analysis.Pass, structName string, field ast.Field) {
if len(field.Names) == 0 {
pass.Reportf(field.Pos(), "Struct \"%s\" has unnamed field", structName)
}
}