skip dirs without go files

This commit is contained in:
asoseil 2017-12-27 14:14:14 +01:00
parent 5929e65b9d
commit 00d1d21d92
1 changed files with 13 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package realize
import ( import (
"bytes" "bytes"
"errors" "errors"
"io/ioutil"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"strings" "strings"
@ -95,6 +96,18 @@ func (t *Tool) Exec(path string, stop <-chan bool) (response Response) {
if filepath.Ext(path) != "" { if filepath.Ext(path) != "" {
path = filepath.Dir(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") { } else if !strings.HasSuffix(path, ".go") {
return return
} }