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

p9: overhaul to support new io/fs package in Go 1.16 #70

Open
DeedleFake opened this issue Nov 13, 2020 · 2 comments
Open

p9: overhaul to support new io/fs package in Go 1.16 #70

DeedleFake opened this issue Nov 13, 2020 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@DeedleFake
Copy link
Owner

See golang/go#41190 and the documentation.

Unfortunately, the new package only supports read-only filesystems, so a straight implementation of those interfaces won't necessarily make a lot of sense. However, I think that it does make sense to try to get the interfaces to match those in io/fs as much as possible. For example, Remote should probably implement fs.File, and possibly fs.FS as well. Similarly, while it will probably be a bit more awkward, it would be nice if FileSystem, Attachment, and File got changed to embed fs.FS and fs.File, with additions as necessary. Renaming some of them might make sense, too.

@DeedleFake DeedleFake added the enhancement New feature or request label Nov 13, 2020
@DeedleFake DeedleFake self-assigned this Nov 13, 2020
@DeedleFake
Copy link
Owner Author

DeedleFake commented Nov 18, 2020

Plan for Remote

Remote will implement fs.FS, fs.File, and fs.ReadDirFile. Walking will be handled entirely by Open(), and actually opening the file through 9P will be done lazily when Read() or Write() are called. Open() will have to be changed to return an fs.File instead of a *Remote directly, but it'll document that it's just a *Remote underneath, so anyone who's using it directly can just do an assertion.

On top of these changes, DirEntry will be changed to implement both fs.FileInfo and fs.DirEntry. It already mostly implements fs.FileInfo, so this change is fairly minor, but it will require the removal of FileMode in favor of fs.FileMode. This will probably have a couple of annoying edge-cases, but it should simplify things in the long-run.

@DeedleFake
Copy link
Owner Author

Plan for FileSystem, File, and Attachment

This is slightly trickier. FileSystem is going to stay as it is, but be renamed to Attacher. Auth will become optional to implement via a second interface, Auther. Attacher.Attach(), meanwhile, will be changed to return an fs.FS. File and Attachment will be replaced with fs.File and fs.FS, respectively, with other functionality, such as writing, being relegated to optional interfaces.

An alternative is to provide a function which takes an fs.FS and returns a Attachment, making it relatively easy to just do this manually on the client's end and requiring far fewer changes internally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant