ReadDir and DirEntry
Let’s learn about the functionality of ReadDir and DirEntry.
We'll cover the following...
We'll cover the following...
This lesson discusses os.ReadDir() and os.DirEntry. However, it begins by discussing the deprecation of the io/ioutil package—the functionality of the io/ioutil package has been transferred to other packages. So, we have the following:
- os.ReadDir(), which is a new function, returns- []DirEntry. This means that it can’t directly replace- ioutil.ReadDir(), which returns- []FileInfo. Although neither- os.ReadDir()nor- os.DirEntryoffer any new functionality, they make things faster and simpler, which is important.
- The - os.ReadFile()function directly replaces- ioutil.ReadFile(). ...