Skip to content
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/fs: document ownership of slice from ReadDirFile.ReadDir #63919

Open
dsnet opened this issue Nov 2, 2023 · 2 comments
Open

io/fs: document ownership of slice from ReadDirFile.ReadDir #63919

dsnet opened this issue Nov 2, 2023 · 2 comments
Labels
Documentation NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@dsnet
Copy link
Member

dsnet commented Nov 2, 2023

The ReadDirFile.ReadDir method returns a []DirEntry, but ownership of the slice is unspecified:

  • Can the caller expect that the results won't be changed by a subsequent ReadDir call?
  • Can the caller mutate the resulting slice?
  • Can the content of each DirEntry be expected to not change?
@dsnet
Copy link
Member Author

dsnet commented Nov 2, 2023

I should note that the implementation of fs.ReadDir assumes that ownership of the slice is given to the caller since it takes the slice returned by ReadDirFile.ReadDir and passes it verbatim to the caller.

@cherrymui
Copy link
Member

cc @rsc @ianlancetaylor

@cherrymui cherrymui added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 3, 2023
@cherrymui cherrymui added this to the Backlog milestone Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants