Readdir returns a []os.FileInfo. os.FileInfo is an interface that is supported by pathLangFileFi(I should have picked a better name for that interface, but it is an internal interface). I need to revisit and clean up this, but you will find other and similar examples.
In Hugo 0.42 we added theme composition/inheritance, which is powered by Afero. We have one filesystem for templates. So I can say give me “_default/single.html” and it will give me the correct version. But there are times when I need to know the real absolute filename to this file on disk (the new SASS/SCSS feature is one example. Libsass doesn’t know about Hugo’s virtual filesystems).
So all of these filesystems supports the filesystems.RealFilenameInfo interface, which will reveal the real filename.