List directory in Go

前端 未结 6 746
夕颜
夕颜 2020-12-07 07:37

I\'ve been trying to figure out how to simply list the files and folders in a single directory in Go.

I\'ve found filepath.Walk, but it goes into sub-directories aut

6条回答
  •  余生分开走
    2020-12-07 07:59

    ioutil.ReadDir is a good find, but if you click and look at the source you see that it calls the method Readdir of os.File. If you are okay with the directory order and don't need the list sorted, then this Readdir method is all you need.

提交回复
热议问题