package service import ( "go/ast" ) var ( includeDeclarations []*Include ) type Include struct { i *ast.ImportSpec } func NewInclude(i *ast.ImportSpec) *Include { return &Include{i: i} } func (i *Include) String() (code string) { code += i.genString(i.i) return } func (i *Include) genString(s *ast.ImportSpec) (code string) { if s.Name != nil { name := handleIdentExpr(s.Name) name = RemapCode(name) if name != "" { if name != "controller" { code = "#include <" + name + ".h>\n" } } } return } func handleImportSpec(s *ast.ImportSpec) (code string) { addInclude(s) return } func addInclude(s *ast.ImportSpec) { c := NewInclude(s) includeDeclarations = append(includeDeclarations, c) }