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: provide package-level documentation for the package #64374

Open
matttproud opened this issue Nov 24, 2023 · 2 comments
Open

io/fs: provide package-level documentation for the package #64374

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

Comments

@matttproud
Copy link
Contributor

matttproud commented Nov 24, 2023

Proposal Details

Related to #64373, I would like to recommend that package fs gets some more top-level package documentation. At present, all that it states is:

Package fs defines basic interfaces to a file system. A file system can be provided by the host operating system but also by other packages.

This provides no information about the package's use and philosophy. There is a proposal document for package fs's design, but that would not be a suitable drop-in replacement to describe use. A couple of things come to mind that are worth mentioning that are not obvious:

  1. For casual use, the a user of the package should primarily rely upon the package's top-level functions when they exist versus specialized interface methods. For instance, use function fs.ReadFile on a fs.FS instead of caring whether a fs.FS implements fs.ReadFileFS (runtime type assertion) and then calling (fs.ReadFileFS).ReadFile directly on the asserted value.

  2. The package's documentation should suggest/tease a couple of common entrypoints for file system access and creation:

    • os.DirFS creates a filesystem around an ordinary POSIX file system.
    • package embed can provide embedded file systems in the binary.

    Without this information, it leaves a reader to wonder whether there are any batteries included, which is not a good developer experience.

  3. The package's top-level documentation should demonstrate some common workflows, too. That would help make many of these points non-issues. There is one package example in the documentation (for WalkDir). If a user's new to this package, the WalkDir example may not be the best foray to demonstrate it.

There are enough symbols floating around in this package's identifier space that it's rather hard to tease apart critical API versus secondary API, which hinders overall comprehension of the package.

@gopherbot gopherbot added this to the Proposal milestone Nov 24, 2023
@seankhliao seankhliao changed the title proposal: io/fs: Provide Package-Level Documentation for the Package io/fs: Provide Package-Level Documentation for the Package Nov 24, 2023
@seankhliao seankhliao removed this from the Proposal milestone Nov 24, 2023
@seankhliao
Copy link
Member

removing from proposal process, it should be fine to just submit CLs.

@gnoack
Copy link
Contributor

gnoack commented Nov 24, 2023

...and as a counterpart to point 1, a section for how to properly implement a new file system would help as well. After all, those are also outside users of the io/fs package.

There are some subtleties especially when wrapping and composition of filesystems is involved where the results might not implement the same "extension interfaces" any more which the input file system did implement. (e.g. if a file system does not implement Sub(), using fs.Sub() can result in a file system that implements fewer extension interfaces than the input file system)

Most of this is probably already explained in the resources that surrounded the creation of this package, but that is not obvious from the existing documentation:

@seankhliao seankhliao changed the title io/fs: Provide Package-Level Documentation for the Package io/fs: provide package-level documentation for the package Nov 24, 2023
@seankhliao seankhliao added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 24, 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

4 participants