The Go code in this section is saved as find.go and will be presented in three parts. As you will see, find.go uses a large amount of the code found in traverse.go, which is the main benefit you get when you are developing a program step by step.
The first part of find.go is the expected preamble:
package main import ( "flag" "fmt" "os" "path/filepath" )
As we already know that we will improve find.go in the near future, the flag package is used here even if this is the first version of find.go and it does not have any flags!
The second part of the Go code contains the implementation of the walkFunction():
func walkFunction(path string, info os.FileInfo, err error) error { fileInfo, err := os.Stat(path) if err != nil { return err } mode := fileInfo.Mode() ...