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: add ModeIrregular flag #23878

Closed
dsnet opened this issue Feb 16, 2018 · 7 comments
Closed

os: add ModeIrregular flag #23878

dsnet opened this issue Feb 16, 2018 · 7 comments

Comments

@dsnet
Copy link
Member

@dsnet dsnet commented Feb 16, 2018

The os.FileInfo type is an interface, allowing other packages to implement it. One of the fields it returns is Mode which reports two pieces of information: 1) what the permissions are, and 2) what type of file it is. There is a helper method os.FileMode.IsRegular that reports whether the file is regular or not. Currently the only way to have IsRegular report false is to set the type to be one of the following:

  • ModeDir | ModeSymlink | ModeNamedPipe | ModeSocket | ModeDevice

For some implementations of os.FileInfo (see #22903 for an example), we want to be able to indicate that the file is not regular. However, every one of the aforementioned types to indicate non-regular are ill-suited as a general-purpose "unknown" file type.

Thus, I propose adding a ModeUnknown to serve exactly for that purpose. The ModeUnknown type carries no information other than the fact that the file is not regular.

CL/94856 is one such implementation.

\cc @bradfitz @ianlancetaylor @robpike @rsc

@gopherbot gopherbot added this to the Proposal milestone Feb 16, 2018
@gopherbot gopherbot added the Proposal label Feb 16, 2018
@rsc

This comment has been minimized.

Copy link
Contributor

@rsc rsc commented Feb 26, 2018

"Unknown" sounds like not knowing anything. We know it's not regular.
ModeOther? ModeIrregular? ModeSpecial?

@rsc

This comment has been minimized.

Copy link
Contributor

@rsc rsc commented Feb 26, 2018

Does sound worth doing though, modulo the name.

@dsnet

This comment has been minimized.

Copy link
Member Author

@dsnet dsnet commented Feb 26, 2018

ModeIrregular SGTM. The name exactly reflects what it means.

@rsc rsc changed the title proposal: os: add ModeUnknown flag os: add ModeIrregular flag Mar 5, 2018
@rsc rsc modified the milestones: Proposal, Go1.11 Mar 5, 2018
@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Mar 28, 2018

Change https://golang.org/cl/94856 mentions this issue: os: add ModeIrregular flag

@gopherbot gopherbot closed this in dfd7f35 Mar 29, 2018
@bradfitz

This comment has been minimized.

Copy link
Contributor

@bradfitz bradfitz commented Mar 30, 2018

Was reverted. Reopening.

@dsnet

This comment has been minimized.

Copy link
Member Author

@dsnet dsnet commented Mar 30, 2018

We ended up rolling forward with a fix in: https://go-review.googlesource.com/103616
So the revert didn't happen.

@dsnet dsnet closed this Mar 30, 2018
@bradfitz

This comment has been minimized.

Copy link
Contributor

@bradfitz bradfitz commented Mar 30, 2018

Ah, whoops. Great. I approved the API change (+ saw the revert CL created) but I missed that the revert was abandoned.

@golang golang locked and limited conversation to collaborators Mar 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.