code: func Visit(path string, visitor VisitFn) error {
  	f, err := os.Open(path)
  	if err != nil {
  		return fmt.Errorf("error reading %q: %v", path, err)
  	}
  	defer f.Close()
  
  	fi, err := f.Stat()
  	if err != nil {
  		return fmt.Errorf("error checking %q: %v", path, err)
  	}
  
  	if !fi.IsDir() {
  		if err := visitor(path); err != nil {
  			return fmt.Errorf("error in %q: %v", path, err)
  		}
  		return nil
  	}
  
  	contents, err := f.Readdir(-1)
  	if err != nil {
  		return fmt.Errorf("error listing %q: %v", path, err)
  	}
  
  	sort.Sort(dirEnts(contents))
  	for _, fi := range contents {
  		if fi.IsDir() {
  			continue
  		}
  
  		fullPath := filepath.Join(path, fi.Name())
  		if err := visitor(fullPath); err != nil {
  			return fmt.Errorf("error in %q: %v", fullPath, err)
  		}
  	}
  
  	return nil
  }
docs: // Visit will call the visitor function on the path if it's a file, or for each
  // file in the path if it's a directory. Directories will not be recursed into,
  // and files in the directory will be visited in alphabetical order.