Added prefix flag, and changed file name output accordingly. Also

changed parser package ParsePackage() to take prefix and updated
skip conditional as needed.  Last paragraph of main package comment
was updated, along with the second to last paragraph of readme.

Due to confusion about import paths, the parser package import path
was left pointing to original repo with the hope that the author will
pull these changes.  Otherwise, the import path will need to be
changed back to the forked repo to work properly.
This commit is contained in:
Daved 2015-04-06 21:33:43 -07:00
parent e9a38094fb
commit 02f6b2afc6
3 changed files with 13 additions and 8 deletions

View file

@ -30,7 +30,7 @@ type Package struct {
}
// ParsePackage parses the package in the given directory and returns it.
func ParsePackage(directory string, skipSuffix string) (*Package, error) {
func ParsePackage(directory, skipPrefix, skipSuffix string) (*Package, error) {
pkgDir, err := build.Default.ImportDir(directory, 0)
if err != nil {
return nil, fmt.Errorf("cannot process directory %s: %s", directory, err)
@ -40,7 +40,8 @@ func ParsePackage(directory string, skipSuffix string) (*Package, error) {
fs := token.NewFileSet()
for _, name := range pkgDir.GoFiles {
if !strings.HasSuffix(name, ".go") ||
(skipSuffix != "" && strings.HasSuffix(name, skipSuffix)) {
(skipSuffix != "" && strings.HasPrefix(name, skipPrefix) &&
strings.HasSuffix(name, skipSuffix)) {
continue
}
if directory != "." {