-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: os: fast, comprehensive directory API #41265
Comments
Redesigning the os.File interface is explicitly out of scope for the io/fs proposal. |
I'll retarget this proposal to the os package. |
Please stop. We are not redesigning the os package either. |
Apologies if I've given offense somehow. #41188 looks like a non-starter. Could a better directory API land in the x/ repo? (I completed the revisions I'd started above, dropping the io/fs references.) |
Every person and every project has limited bandwidth for making decisions well, especially given the large amounts of time it can take to evaluate an idea fully. Redesigning the os.File API is not on our priority list right now. I'm sorry if that priority conflicts with yours, but again we have limited time and need to focus on higher-impact things. It is of course fine to build your own APIs in a third-party package, as always. |
Then would you tag this "Proposal-Hold" instead of closing? You're gonna need it eventually :-) |
A few things.
|
Based on the discussion above, this seems like a likely decline. |
Thankfully that didn't turn out to be true :-) |
No change in consensus, so declined (and retracted). |
This is an alternative to #41188, which seems impractical. It offers a replacement for
os.Readdir()
&os.Readdirnames()
. We need a new API to address performance problems and missing features in the current one.Previous discussion...
ReadDir()
argument gives fields to populateDirEntry
gets native dirent fields and lazy-loads others; .Has() indicates is-loadedThe API below meets all the requirements discussed. It provides explicit lazy-loading, ensures that all accessible fields have data from the same retrieval, and avoids an error check after every field access.
Use cases: When you need...
a) certain fields for every item, request them in
ReadDirItems()
.b) certain fields for some items, request them in
DirItem.Load()
.c) any fields of the OS defaults that aren't universal, check for them with
DirItem.Has()
before access.d) implementation-specific fields, request them as above, then check for them with
DirItem.Has()
before access.e) the latest data for an item, request it with
DirItem.Load()
.cc @robpike @rsc
The text was updated successfully, but these errors were encountered: