@@ -69,28 +69,26 @@ func parseRawConnectorSchemaFromGoCode(ctx context.Context, moduleName string, f
69
69
tempDirs = append (tempDirs , entry .Name ())
70
70
}
71
71
}
72
- var directories []string
72
+
73
+ directories := make (map [string ]bool )
73
74
for _ , dir := range tempDirs {
74
75
for _ , globPath := range []string {path .Join (filePath , dir , "*.go" ), path .Join (filePath , dir , "**" , "*.go" )} {
75
76
goFiles , err := filepath .Glob (globPath )
76
77
if err != nil {
77
78
return nil , fmt .Errorf ("failed to read subdirectories of %s/%s: %w" , filePath , dir , err )
78
79
}
79
- // cleanup types.generated.go files
80
- fileCount := 0
80
+
81
81
for _ , fp := range goFiles {
82
82
if ! strings .HasSuffix (fp , typeMethodsOutputFile ) {
83
- fileCount ++
83
+ directories [ filepath . Dir ( fp )] = true
84
84
continue
85
85
}
86
- if err := os .Remove (fp ); err != nil {
86
+
87
+ // cleanup types.generated.go files
88
+ if err := os .Remove (fp ); err != nil && ! os .IsNotExist (err ) {
87
89
return nil , fmt .Errorf ("failed to delete %s: %w" , fp , err )
88
90
}
89
91
}
90
- if fileCount > 0 {
91
- directories = append (directories , dir )
92
- break
93
- }
94
92
}
95
93
}
96
94
@@ -99,7 +97,7 @@ func parseRawConnectorSchemaFromGoCode(ctx context.Context, moduleName string, f
99
97
100
98
var packageList []* packages.Package
101
99
fset := token .NewFileSet ()
102
- for _ , folder := range directories {
100
+ for folder := range directories {
103
101
_ , parseCodeTask := trace .NewTask (ctx , fmt .Sprintf ("parse_%s_code" , folder ))
104
102
folderPath := path .Join (filePath , folder )
105
103
cfg := & packages.Config {
0 commit comments