ReadDir and DirEntry
Let’s learn about the functionality of ReadDir and DirEntry.
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 replaceioutil.ReadDir(), which returns[]FileInfo. Although neitheros.ReadDir()noros.DirEntryoffer any new functionality, they make things faster and simpler, which is important.The
os.ReadFile()function directly replacesioutil.ReadFile(). ...
Ask