Hacker News new | ask | show | jobs
by noisem4ker 1751 days ago
I can see cli.go invokes syscall.Getdents(...), which is a Linux system call, so I'd say Linux, even if Go is supposed to be multi-platform.
1 comments

Is POSIX readdir() not available with Go? readdir is just thin veneer over getdents on Linux, so if readdir is available it'd be a much more portable choice.

EDIT: A reason to use getdents() over readdir() would be not having to stat to get the file type.

EDIT2: "ls" in GNU coreutils will actually get the file type from readdir() guarded by a feature flag to determine whether d_type is available on the platform in question, so clearly you can get d_type from readdir() too. No idea about accessing it from Go, though.