Directory
- How to list files in a directory using Go [2023]
In Go there are a couple of options to list the files of a directory using the standard library. In this article you will find a list of three different methods.
Note: Be aware that
ioutil.ReadDiris deprecated since Go 1.16. Insteados.ReadDirshould be used (shown in this article).os.ReadDir
os.ReadDir is included in the standard library in the os package. Check out the documentation for more information. It’s a drop in replacement from
ioutil.ReadDir.