doc.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. Package godirwalk provides functions to read and traverse directory trees.
  3. In short, why do I use this library?
  4. * It's faster than `filepath.Walk`.
  5. * It's more correct on Windows than `filepath.Walk`.
  6. * It's more easy to use than `filepath.Walk`.
  7. * It's more flexible than `filepath.Walk`.
  8. USAGE
  9. This library will normalize the provided top level directory name based on the
  10. os-specific path separator by calling `filepath.Clean` on its first
  11. argument. However it always provides the pathname created by using the correct
  12. os-specific path separator when invoking the provided callback function.
  13. dirname := "some/directory/root"
  14. err := godirwalk.Walk(dirname, &godirwalk.Options{
  15. Callback: func(osPathname string, de *godirwalk.Dirent) error {
  16. fmt.Printf("%s %s\n", de.ModeType(), osPathname)
  17. return nil
  18. },
  19. })
  20. This library not only provides functions for traversing a file system directory
  21. tree, but also for obtaining a list of immediate descendants of a particular
  22. directory, typically much more quickly than using `os.ReadDir` or
  23. `os.ReadDirnames`.
  24. */
  25. package godirwalk