- I need to write a function which when given the path of a folder scans the files rooted at that folder.
- And then I need to display the directory structure at that folder.
I know how to do 2 (I am going to use jstree to display it in the browser).
I know how to do 2 (I am going to use jstree to display it in the browser).
You might want to do function currying here, so that you are able to fully utilise the search
func visit(files *[]string) filepath.WalkFunc {
return func (path string, info os.FileInfo, err error) error {
// maybe do this in some if block
*files = append(*files, path)
return nil
}
}
func printAllFilesRecursively(input string) {
filesInfo, _ := ioutil.ReadDir(input)
for _, each := range filesInfo {
println(input + "/" + each.Name())
if each.IsDir() {
printAllFilesRecursively(input + "/" + each.Name())
}
}
}