Created
January 4, 2018 14:51
-
-
Save innermond/568e9c3ab9dc2f6854ae706704f8c782 to your computer and use it in GitHub Desktop.
Walk all the way down the folder hierachy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"os/user" | |
"path/filepath" | |
) | |
func main() { | |
usr, _ := user.Current() | |
p := filepath.Join(usr.HomeDir, <path segment>, <other path segment>) | |
filepath.Walk(p, func(fn string, fi os.FileInfo, err error) error { | |
if err != nil { | |
fmt.Println(err) | |
return err | |
} | |
fn = fn[len(p):] | |
fmt.Printf("%s %v\n", fn, fi.IsDir()) | |
return nil | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment