3 ms·
>why they'd add an interface that accumulates everything into a giant array by default While I can't speak for Go's authors' mindset, here's my view: One arra
by dexen 6y ago
>why they'd add an interface that accumulates everything into a giant array by default
While I can't speak for Go's authors' mindset, here's my view:
One array of records is about as simple interface as possible, and it's good enough for many use cases. Contrasting with that, reading the directory with repeated readdir()'s or equivalent is fraught with hidden pitfalls. You end up being responsible for sorting, for resuming syscall in case of a signal or other interruption, for handling changes to the list of files during read... and probably other concerns above and beyond that.
- sanderjd 6y agoThe suggestion isn't repeated readdir calls, it is some kind of iterator, which would specify and be implemented to solve the problems you mention (which already have to be dealt with inside the array-returning readdir call, by the way).