Merge pull request #218 from bobappleyard/master

Issue #217: handling of _test.go files
This commit is contained in:
GoWebProd
2020-03-30 23:19:08 +03:00
committed by GitHub
+6 -1
View File
@@ -5,6 +5,7 @@ import (
"go/ast"
"go/parser"
"go/token"
"os"
"os/exec"
"strings"
)
@@ -73,7 +74,7 @@ func (p *Parser) Parse(fname string, isDir bool) error {
fset := token.NewFileSet()
if isDir {
packages, err := parser.ParseDir(fset, fname, nil, parser.ParseComments)
packages, err := parser.ParseDir(fset, fname, excludeTestFiles, parser.ParseComments)
if err != nil {
return err
}
@@ -96,3 +97,7 @@ func getDefaultGoPath() (string, error) {
output, err := exec.Command("go", "env", "GOPATH").Output()
return string(bytes.TrimSpace(output)), err
}
func excludeTestFiles(fi os.FileInfo) bool {
return !strings.HasSuffix(fi.Name(), "_test.go")
}