Files
gormlint/common/resolveBaseType.go
GogaCoder 49878c333c feat: references check
... and fixes: parse fields without tags and other logical errors
2024-12-30 21:15:15 +07:00

22 lines
375 B
Go

package common
import (
"go/ast"
)
func ResolveBaseType(expr ast.Expr) *string {
switch e := expr.(type) {
case *ast.Ident:
return &e.Name
case *ast.StarExpr:
return ResolveBaseType(e.X)
case *ast.ArrayType:
return ResolveBaseType(e.Elt)
case *ast.SelectorExpr:
return ResolveBaseType(e.X)
case *ast.ParenExpr:
return ResolveBaseType(e.X)
}
return nil
}