type Scanner … // NewScanner returns a new directory Scanner that lazily enumerates // the contents of a single directory. To prevent resource leaks, // caller must invoke either the Scanner's Close or Err method after // it has completed scanning a directory. // // scanner, err := godirwalk.NewScanner(dirname) // if err != nil { // fatal("cannot scan directory: %s", err) // } // // for scanner.Scan() { // dirent, err := scanner.Dirent() // if err != nil { // warning("cannot get dirent: %s", err) // continue // } // name := dirent.Name() // if name == "break" { // break // } // if name == "continue" { // continue // } // fmt.Printf("%v %v\n", dirent.ModeType(), dirent.Name()) // } // if err := scanner.Err(); err != nil { // fatal("cannot scan directory: %s", err) // } func NewScanner(osDirname string) (*Scanner, error) { … } // NewScannerWithScratchBuffer returns a new directory Scanner that // lazily enumerates the contents of a single directory. On platforms // other than Windows it uses the provided scratch buffer to read from // the file system. On Windows the scratch buffer is ignored. To // prevent resource leaks, caller must invoke either the Scanner's // Close or Err method after it has completed scanning a directory. func NewScannerWithScratchBuffer(osDirname string, scratchBuffer []byte) (*Scanner, error) { … } // Close releases resources associated with scanning a directory. Call // either this or the Err method when the directory no longer needs to // be scanned. func (s *Scanner) Close() error { … } // Dirent returns the current directory entry while scanning a directory. func (s *Scanner) Dirent() (*Dirent, error) { … } // done is called when directory scanner unable to continue, with either the // triggering error, or nil when there are simply no more entries to read from // the directory. func (s *Scanner) done(err error) { … } // Err returns any error associated with scanning a directory. It is // normal to call Err after Scan returns false, even though they both // ensure Scanner resources are released. Call either this or the // Close method when the directory no longer needs to be scanned. func (s *Scanner) Err() error { … } // Name returns the base name of the current directory entry while scanning a // directory. func (s *Scanner) Name() string { … } // Scan potentially reads and then decodes the next directory entry from the // file system. // // When it returns false, this releases resources used by the Scanner then // returns any error associated with closing the file system directory resource. func (s *Scanner) Scan() bool { … }