Guest User

Untitled

a guest
Mar 17th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4. "fmt"
  5. "io/ioutil"
  6. "log"
  7. "os"
  8. "path/filepath"
  9. )
  10.  
  11. func main() {
  12. var (
  13. root string
  14. files []string
  15. err error
  16. )
  17.  
  18. if len(os.Args) == 1 {
  19. log.Fatal("No path given, Please specify path.")
  20. return
  21. }
  22. if root = os.Args[1]; root == "" {
  23. log.Fatal("No path given, Please specify path.")
  24. return
  25. }
  26. // filepath.Walk
  27. files, err = FilePathWalkDir(root)
  28. if err != nil {
  29. panic(err)
  30. }
  31. // ioutil.ReadDir
  32. files, err = IOReadDir(root)
  33. if err != nil {
  34. panic(err)
  35. }
  36. //os.File.Readdir
  37. files, err = OSReadDir(root)
  38. if err != nil {
  39. panic(err)
  40. }
  41.  
  42. for _, file := range files {
  43. fmt.Println(file)
  44. }
  45. }
Add Comment
Please, Sign In to add comment