Added prefix flag, and updated file name output. Changed parser

package's ParsePackage to take prefix and updated related skip
conditional.  Also updated args in call to ParsePackage within
server. Last paragraph of main package comment was updated, along
with the second to last paragraph of readme.
This commit is contained in:
Daved 2015-04-23 09:50:48 -07:00
parent 3699e12530
commit c55a706513
4 changed files with 14 additions and 9 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 != "." {