Go 1.16 introduces os.ReadDir and the DirEntry interface, bringing performance improvements to directory reading by exposing file type information directly from OS calls — eliminating the need for extra stat calls per entry. The author, who originally designed Python's os.scandir, compares the two APIs side by side, showing how both languages evolved from slower listdir/ioutil.ReadDir approaches. The post also covers the new filepath.WalkDir function, which replaces filepath.Walk to deliver speed gains (roughly 1.5x on local Linux, much more on network file systems), and explains why the existing FileInfo interface couldn't be reused due to error-handling concerns.

8m read timeFrom benhoyt.com
Post cover image
Table of contents
Why is ReadDir needed?Python vs GoHigher-level tree walkingSummary
1 Impression