Go path/filepath Package Walk()

Introduction

To recursively walk a folder and read the folder's contents, all the sub folders, all the sub-sub folders, etc.

package main /*from w w  w . jav  a 2 s.  c  o m*/

import ( 
    "fmt" 
    "os" 
    "path/filepath" 
) 

func main() { 
    filepath.Walk(".", func(path string, info os.FileInfo, err error) error { 
        fmt.Println(path) 
        return nil 
    }) 
} 



PreviousNext

Related