Skip to content

io/fs, testing/testfs: disagreement about whether Open(".") must succeed #44310

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

Closed
josharian opened this issue Feb 16, 2021 · 1 comment
Closed
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@josharian
Copy link
Contributor

(Sorry for filing all these right around when 1.16 was released, not before. Just bad luck timing.)

I implemented what I thought was the simplest possible empty filesystem:

func (f *FS) Open(name string) (fs.File, error) {
	return nil, &fs.PathError{Op: "open", Path: name, Err: fs.ErrNotExist}
}

It seems to me that according to the io/fs docs, this is a valid empty filesystem.

testing/fstest.TestFS doesn't like it, though:

--- FAIL: TestEmptyFS (0.01s)
    fs_test.go:10: TestFS found errors:
        .: Open: open .: file does not exist

Is TestFS wrong? Or are there missing docs requiring the file "." to be openable?

cc @rsc

P.S. golang.org/s/owners doesn't list any owners for io/fs and testing/fstest.

@toothrot toothrot added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 17, 2021
@toothrot toothrot added this to the Backlog milestone Feb 17, 2021
@seankhliao
Copy link
Member

I this it should be covered by:

the name "." may be used for the root directory.

As a directory, it must exist, and therefore be openable, even if it is empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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