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

os: document DirFS implements fs.StatFS #51856

Closed
wbourne0 opened this issue Mar 21, 2022 · 2 comments
Closed

os: document DirFS implements fs.StatFS #51856

wbourne0 opened this issue Mar 21, 2022 · 2 comments
Labels
Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.

Comments

@wbourne0
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.18 linux/amd64

The change which added .Stat

Does this issue reproduce with the latest release?

Yes - this issue exists in >=17 (change to implement fs.StatFS introduced here)

What operating system and processor architecture are you using (go env)?

n/a

What did you do?

https://go.dev/play/p/PdBdag3nnUd

Use .Stat on the result of os.DirFS.

What did you expect to see?

The program should compile and stat the file.

os.DirFS should return fs.StatFS instead of a fs.FS as os.dirFS implements fs.StatFS.

Same result as it would be if manually casting to fs.StatFS - https://go.dev/play/p/2T4F9981gzE?v=gotip

What did you see instead?

./prog.go:12:17: fs.Stat undefined (type fs.FS has no field or method Stat)

Go build failed.

There might be a reason for os.DirFS returns fs.FS instead of fs.StatFS but I didn't see any comments on the change introducing it that mentioned one.

@seankhliao
Copy link
Member

Changing the return type of os.DirFS would be a breaking change.
The additional interfaces of io/fs are meant as extensions to be tested for before being used (that's why each only defines a single extra method).

@seankhliao seankhliao changed the title os: return type for DirFS should be fs.StatFS os: document DirFS implements fs.StatFS Mar 21, 2022
@seankhliao seankhliao added Documentation NeedsFix The path to resolution is known, but the work has not been done. labels Mar 21, 2022
@gopherbot
Copy link

Change https://go.dev/cl/394555 mentions this issue: os: document DirFS implements fs.StatFS

@golang golang locked and limited conversation to collaborators Mar 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants