:= range f.Decls { d, ok := decl.(*ast.GenDecl ) if !ok || d.Tok != token.TYPE { continu e } for _, spec := range d.Specs { s, ok := spec.(*ast.TypeSpec ) if !ok { continu e } t, ok := s.Type.(*ast.StructType ) if !ok { continu e } structASTMap[s.Name.Name] = t } } } https://github.com/riita10069/roche/blob/master/pkg/rochectl/ast/ fi nd-struct.go func GetPropertyByStructAst(structAst *ast.StructType) ([]string, []string) { var properties []strin g var propertiesType []strin g for _, field := range structAst.Fields.List { for _, nameIdent := range field.Names { switch field.Type.(type) { case *ast.SelectorExpr : selectorExpr, _ := field.Type.(*ast.SelectorExpr ) xIdent, _ := selectorExpr.X.(*ast.Ident ) if xIdent.Name == "protoimpl" { continu e } properties = append(properties, util.SnakeToLowerCamel(nameIdent.Name) ) propertiesType = append(propertiesType, xIdent.Name ) case *ast.Ident : ident, _ := field.Type.(*ast.Ident ) properties = append(properties, nameIdent.Name ) propertiesType = append(propertiesType, ident.Name ) } } } return properties, propertiesTyp e }