-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: let FileInfo type also contain the full path, not just basename #32300
Comments
You showed the FileInfo interface, though. File does contain the original path that was opened:
|
Sorry, my bad. To give you an example of what I usually do:
And then, in the |
Right; then the issue should be about FileInfo to be clear. In that case I'd simply pass the directory path along with each file. Then you can join the path with the basename easily. I'm not sure that this is a big issue. |
This indeed can be a workaround, but I don't see why the full filepath couldn't be part of the fileInfo struct. |
a) for go1compat reasons, we can't extend the FileInfo interface, even if we wanted to. b) a full path name isn't always available/known/unique. There could be multiple paths to a file, and only some paths that are accessible to the current user. From the point of view of Readdir, it only gets the base names from the operating systems, so that's all it can return anyway. The Closing, because there's nothing we can do here. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What did you do?
I often use the FileInfo type to work with files. The file struct now contains the following:
Now I was wondering: why doesn't it contain the full path to the file? I often pass around a File to functions, but I see myself always reconstruct the full path, which -in my opinion- could also be part of the File itself.
#just wondering
The text was updated successfully, but these errors were encountered: