Skip to content

Commit

Permalink
find-fast provides --skip PATTERN to skip entries (typo corrected)
Browse files Browse the repository at this point in the history
Ref: #53

Returning the special value `filepath.SkipDir` as an error token is
supported by `filepath.Walk` and by `godirwalk.Walk` to configure the
walk function to not descend further in the directory hierarchy of the
current file system entry.

This change updates the example find-fast program to demonstrate use
of this token error value.
  • Loading branch information
Karrick S. McDermott committed Aug 10, 2020
1 parent 1b74140 commit 6e40020
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions examples/find-fast/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func main() {
case nameRE == nil:
// When no name pattern provided, print everything.
options.Callback = func(osPathname string, _ *godirwalk.Dirent) error {
if *optSkip != "" && strings.Contains(osPathname, ".git") {
if *optSkip != "" && strings.Contains(osPathname, *optSkip) {
return filepath.SkipDir
}
_, err := fmt.Println(osPathname)
Expand All @@ -65,7 +65,7 @@ func main() {
case NoColor:
// Name pattern was provided, but color not permitted.
options.Callback = func(osPathname string, _ *godirwalk.Dirent) error {
if *optSkip != "" && strings.Contains(osPathname, ".git") {
if *optSkip != "" && strings.Contains(osPathname, *optSkip) {
return filepath.SkipDir
}
var err error
Expand All @@ -79,7 +79,7 @@ func main() {
buf = append(buf, "\033[22m"...) // very first print should set normal intensity

options.Callback = func(osPathname string, _ *godirwalk.Dirent) error {
if *optSkip != "" && strings.Contains(osPathname, ".git") {
if *optSkip != "" && strings.Contains(osPathname, *optSkip) {
return filepath.SkipDir
}
matches := nameRE.FindAllStringSubmatchIndex(osPathname, -1)
Expand Down

0 comments on commit 6e40020

Please sign in to comment.