-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
proposal: path: add IsLocal #63716
Comments
I think it would be nice to have a straightforward way to do this in the standard library, just as proposed. There are already some building blocks in stdlib that can do roughly this in a more roundabout way: func LocalPath(s string) bool {
return fs.ValidPath(path.Clean(s))
}
|
The path package doesn't operate on the filesystem, this seems in conflict with the first point of filepath.IsLocal: "is within the subtree rooted at the directory in which path is evaluated" |
It’s a purely lexical consideration though. It’s not looking at CWD to decide this. I think path is an appropriate package. |
If you take a possible path and clean it then test that it’s local, it will pass fs.ValidPath. |
(CC @neild) |
fs.ValidPath also checks for a trailing slash, so it's not totally equivalent after all. |
|
I personally wouldn't object to I believe
|
There is now filepath.Localize #57151, so I guess this issue is obsolete? You could do |
It would be nice to have a platform independent version of
filepath.IsLocal
. It would be the same the existingfilepath.isLocalUnix
, but usable from Windows.The text was updated successfully, but these errors were encountered: