func main() { var ( args []string total int files chan string ) args = getopt.Parse(os.Args[1:]) switch { case getopt.IsSet("-list"): listing() case getopt.IsSet("-help"): usage() case getopt.IsSet("-match"): addMatchFunc(getopt.Get("-match")) } if len(args) > 0 { root = args[0] } if handy.IsDir(root) { files = walker.ChanWalk(root) total = counter.NewLineFiles(getopt.IsSet("-verbose"), files) } else if handy.IsFile(root) { total = counter.NewLineFile(root) } else { log.Fatalf("[ERROR] '%s' neither file nor directory\n", root) } fmt.Printf("total: %6d\n", total) }
func main() { parseArgv() if help { printHelpAndExit() } addFileFilter() addDirFilter() files := walker.ChanWalk(topdir) for f := range files { fmt.Printf("%s\n", f) } }
func main() { args := getopt.Parse(os.Args[1:]) if getopt.IsSet("-help") { fmt.Println(info) } for i := 0; i < len(args); i++ { if getopt.IsSet("-recursive") && handy.IsDir(args[i]) { for f := range walker.ChanWalk(args[i]) { r := guess.NorwayFile(f) report(f, r) } } else { r := guess.NorwayFile(args[i]) report(args[i], r) } } }