by boring_twenties · 6y ago · 0 comments
What does being aware of the downsides get you?
Is there some alternate interface that avoids the downsides?
You opendir, read 100 entries, do whatever with them, read 100 more, repeat, then closedir. So it's a buffered interface similar to normal I/O.
There's been proposals for doing readdir+stat in one syscall, but nothing merged yet. https://lwn.net/Articles/606995/
Reg downsides: Maybe don't use it on a directory with 1000 entries...? Its good to be aware of that or not?
It’s fine to include an inefficient version if you also have a ‘proper’ way to fall back to when performance does matter. And if performance does not matter, why are you even using Go? Funnily enough Python Ruby and Node do expose performant ways to do this in the stdlib, so...