diff --git a/pkg/service/class.go b/pkg/service/class.go index 4211007..00eb16a 100644 --- a/pkg/service/class.go +++ b/pkg/service/class.go @@ -97,14 +97,8 @@ func (c *Class) AddMethod(m *ast.FuncDecl) { } // Handlers -func handleClass(t *ast.TypeSpec) string { - st, ok := t.Type.(*ast.StructType) - if !ok { - return "" - } - - addClassFromStructType(t.Name.String(), st) - +func handleClass(name string, st *ast.StructType) string { + addClassFromStructType(name, st) return "" } func addClassFromStructType(name string, s *ast.StructType) { diff --git a/pkg/service/spec.go b/pkg/service/spec.go index 29b21eb..3d20dc8 100644 --- a/pkg/service/spec.go +++ b/pkg/service/spec.go @@ -33,7 +33,7 @@ func handleSpecs(specs []ast.Spec) (code string) { case *ast.ValueSpec: code += handleValueSpec(s) + ";" case *ast.TypeSpec: - code += handleTypeSpec(spec) + code += handleTypeSpec(s) } } return diff --git a/pkg/service/type.go b/pkg/service/type.go index 48b28f2..d9eed96 100644 --- a/pkg/service/type.go +++ b/pkg/service/type.go @@ -8,10 +8,17 @@ var ( isPointerType = false ) -func handleTypeSpec(spec ast.Spec) (code string) { - s := spec.(*ast.TypeSpec) - handleClass(s) - return +func handleTypeSpec(s *ast.TypeSpec) (code string) { + st, ok := s.Type.(*ast.StructType) + if ok { + return handleClass(s.Name.String(), st) + } + + return handleType(s) +} + +func handleType(s *ast.TypeSpec) string { + return "" } func handleStructType(s *ast.StructType) (code string) {