Advertisement
pcwizz

Untitled

Nov 29th, 2014
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.66 KB | None | 0 0
  1. func exploreDirectory (string path) ([]string, error){
  2.     var output []string
  3.     //Get entries
  4.     info, err := ioutil.ReadDir(path)
  5.     if err != nil {
  6.         return nil, err
  7.     }  
  8.     for i, _ := range info {
  9.         if !info[i].IsDir() {
  10.             //Output file
  11.             output := append(output, path + "/" + info[i].Name)
  12.         } else {
  13.             //Explore it; it's a directory.
  14.             entries, err := exploreDirectory(path + "/"  + info[i].Name())
  15.             if err != nil {
  16.                 return nil, err
  17.             }  
  18.             output := append(output, entries...)
  19.         }  
  20.     }  
  21.     return output, nil
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement