3 ms·
Yeah, nope. There are many appropriate levels of abstraction in between “do this the dumbest way possible” and “write raw unix syscalls using a library outside
by doteka 6y ago
Yeah, nope. There are many appropriate levels of abstraction in between “do this the dumbest way possible” and “write raw unix syscalls using a library outside of the standard distribution”.
- icholy 6y agoJust because something doesn't work for your use-case doesn't make it the "dumbest way possible". It just makes you sound dumb.
- doteka 6y agoNo, this is literally the dumbest way possible to accomplish the task. It is as close to a brute force approach as you can get, I can see no way in which it could be less efficient without being malicious. And it is the only way of accomplishing this task in the standard library of a language which prides itself on performance and maintainability. Also, thanks for the ad hominem, perhaps you shouldn’t attach your self worth to a programming language and see how that works out for you.
- icholy 6y agoThere's https://golang.org/pkg/os/#File.Readdir https://golang.org/pkg/os/#File.Readdir
- Someone 6y agoWhich, as far as I can tell (couldn’t find opendir/closedir), has the same problem. I think they named the call after the posix one. If so, they must have known about opendir/closedir.
- icholy 6y agoIt uses https://golang.org/pkg/syscall/#ReadDirent https://golang.org/pkg/syscall/#ReadDirent and https://golang.org/pkg/syscall/#ParseDirent https://golang.org/pkg/syscall/#ParseDirent to incrementally read them.