首页 > 其他 > 详细

golang遍历文件夹

时间:2019-06-05 18:15:23      阅读:158      评论:0      收藏:0      [点我收藏+]

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())
        }
    }
}

 

这篇博客纯属充数~~~~~~~

 

golang遍历文件夹

原文:https://www.cnblogs.com/xbblogs/p/10981070.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!