From 00d1d21d925e610705b908142587bf49c8a24971 Mon Sep 17 00:00:00 2001 From: asoseil Date: Wed, 27 Dec 2017 14:14:14 +0100 Subject: [PATCH] skip dirs without go files --- realize/tools.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/realize/tools.go b/realize/tools.go index bbefa9c..ae0b36f 100644 --- a/realize/tools.go +++ b/realize/tools.go @@ -3,6 +3,7 @@ package realize import ( "bytes" "errors" + "io/ioutil" "os/exec" "path/filepath" "strings" @@ -95,6 +96,18 @@ func (t *Tool) Exec(path string, stop <-chan bool) (response Response) { if filepath.Ext(path) != "" { path = filepath.Dir(path) } + // check if there is at least one go file + matched := false + files, _ := ioutil.ReadDir(path) + for _, f := range files { + matched, _ = filepath.Match("*.go", f.Name()) + if matched { + break + } + } + if !matched { + return + } } else if !strings.HasSuffix(path, ".go") { return }