package main import ( "fmt" "os" "git.wecise.com/wecise/util/filewalker" ) // 同步指定文件夹中的内容 func PrintUsage() { println(`Usage: sync `) } func main() { var frompath, topath string if len(os.Args) > 2 { frompath = os.Args[1] topath = os.Args[2] } switch { case frompath != "" && topath != "": sync(frompath, topath) default: PrintUsage() os.Exit(1) } } func sync(frompath, topath string) { fw, err := filewalker.NewFileWalker([]string{frompath}, "") // orderby: dirfirst, filefirst, fullpath if err != nil { println(err.Error()) } err = fw.List(func(basedir, fpath string) bool { fmt.Println(basedir, fpath) return true }) if err != nil { println(err.Error()) } }