From e51cef81d996c349e942f3ba3adad74c4a6edb81 Mon Sep 17 00:00:00 2001 From: Christoph Mewes Date: Mon, 3 May 2021 10:59:14 +0200 Subject: [PATCH] fix exclude filters only working for directories --- config.go | 2 ++ main.go | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/config.go b/config.go index f071f4c..0de374d 100644 --- a/config.go +++ b/config.go @@ -52,6 +52,8 @@ func loadConfiguration(filename string, moduleRoot string) (*Config, error) { // to not muck with generated files "**/zz_generated.**", "**/zz_generated_**", + "**/generated.pb.go", + "**/*_generated.go", // for performance ".git/**", diff --git a/main.go b/main.go index 36901cd..84fa1e2 100644 --- a/main.go +++ b/main.go @@ -168,13 +168,17 @@ func listFiles(start string, moduleRoot string, skips []string) ([]string, error return err } - if d.IsDir() { - for _, skip := range skips { - if match, _ := doublestar.Match(skip, relPath); match { + for _, skip := range skips { + if match, _ := doublestar.Match(skip, relPath); match { + if d.IsDir() { return filepath.SkipDir + } else { + return nil } } - } else if strings.HasSuffix(path, ".go") { + } + + if !d.IsDir() && strings.HasSuffix(path, ".go") { result = append(result, path) }