@@ -187,21 +187,23 @@ func checkDir() error {
187
187
if isCapitalized && info .Name () != "PROJECT" {
188
188
return nil
189
189
}
190
- // Allow files in the following list
191
- allowedFiles := []string {
192
- "go.mod" , // user might run `go mod init` instead of providing the `--flag` at init
193
- "go.sum" , // auto-generated file related to go.mod
190
+ // Deny files with .go or .yaml extensions
191
+ disallowedExtensions := []string {
192
+ ".go" ,
193
+ ".yaml" ,
194
+ ".mod" ,
195
+ ".sum" ,
194
196
}
195
- for _ , allowedFile := range allowedFiles {
196
- if info .Name () == allowedFile {
197
- return nil
197
+ for _ , ext := range disallowedExtensions {
198
+ if strings .HasSuffix (info .Name (), ext ) {
199
+ return fmt .Errorf (
200
+ "target directory is not empty and contains a disallowed file %q \" .\" , " +
201
+ "files with the following extensions [%s] are not allowed to avoid conflicts with the tooling." ,
202
+ path , strings .Join (disallowedExtensions , ", " ))
198
203
}
199
204
}
200
- // Do not allow any other file
201
- return fmt .Errorf (
202
- "target directory is not empty (only %s, files and directories with the prefix \" .\" , " +
203
- "files with the suffix \" .md\" or capitalized files name are allowed); " +
204
- "found existing file %q" , strings .Join (allowedFiles , ", " ), path )
205
+
206
+ return nil
205
207
})
206
208
if err != nil {
207
209
return err
0 commit comments