Last active
August 29, 2015 14:16
-
-
Save mdfranz/4cdfaf1ee5817ce1b859 to your computer and use it in GitHub Desktop.
Simple Directory Lister
This file contains 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
// From https://www.socketloop.com/tutorials/golang-read-directory-content-with-filepath-walk | |
package main | |
import ( | |
"path/filepath" | |
"os" | |
"flag" | |
"fmt" | |
) | |
func walkpath (path string, f os.FileInfo, err error) error { | |
fmt.Printf("%s,%s,%d\n", path,f.ModTime(),f.Size()) | |
return nil | |
} | |
func main() { | |
flag.Parse() | |
root := flag.Arg(0) // 1st argument is the directory location | |
filepath.Walk(root, walkpath) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment