golang遍历文件夹
发布时间:2020-12-16 09:25:10 所属栏目:大数据 来源:网络整理
导读:golang遍历文件夹: ? func main() { // 方式一 filepath.Walk( " temp/ " ,func (path string ,info os.FileInfo,err error) error { fmt.Println(path) return nil }) // 方式二 getFileList( " temp/ " )}func getFileList(path string ) { fs,_: = iouti
golang遍历文件夹: ? func main() { //方式一 filepath.Walk("temp/",func (path string,info os.FileInfo,err error) error { fmt.Println(path) return nil }) //方式二 getFileList("temp/") } func getFileList(path string) { fs,_:= ioutil.ReadDir(path) for _,file:=range fs{ if file.IsDir(){ fmt.Println(path+file.Name()) getFileList(path+file.Name()+"/") }else{ fmt.Println(path+file.Name()) } } } ? 这篇博客纯属充数~~~~~~~ (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |