Skip to content

Instantly share code, notes, and snippets.

@mdfranz
Last active August 29, 2015 14:16
Show Gist options
  • Save mdfranz/4cdfaf1ee5817ce1b859 to your computer and use it in GitHub Desktop.
Save mdfranz/4cdfaf1ee5817ce1b859 to your computer and use it in GitHub Desktop.
Simple Directory Lister
// 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