mirror of
https://github.com/netbirdio/easyjson.git
synced 2026-05-22 18:44:42 -07:00
Merge pull request #218 from bobappleyard/master
Issue #217: handling of _test.go files
This commit is contained in:
+6
-1
@@ -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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user