-
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
io: add FileInfoToDirEntry(FileInfo) #42387
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I can imagine this coming up but I can't imagine it coming up so often it belongs in the standard library. This could certainly be due to a lack of imagination on my part. Why/how has it come up so far? |
@jimmyfrasche It comes up any time you implement ReadDir in an FS implementation. |
Is it because if you have an arbitrary File that you did not implement you can only call Stat on it? You could add a (possibly optional) method like Stat to File that returns a DirEntry. Then only real file systems would need to worry about it and those would be handled by the standard library. |
I don't see anyone objecting to this, and it really does come up every time you try to implement these new interfaces, so it seems like we should include it with the new interfaces. This seems like a likely accept. Better names welcome. |
No change in consensus, so accepted. |
Change https://golang.org/cl/293649 mentions this issue: |
The name is kind of long. I would have preferred |
From our limited experience with #42027, it turns out to be fairly common when using WalkDir or implementing ReadDir to want to create a DirEntry from a FileInfo.
I suggest we add
The name is a bit awkward but I haven't found a better one yet.
/cc @robpike
The text was updated successfully, but these errors were encountered: