-
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
path package should use \ on Windows? #1423
Labels
Comments
This breaks expectations, as referred on my submission, even though Win32 supports forward slashes, no one expects to use them. This breaks compatibility with all the tools that might need to interoperate with Go based applications. All other languages play nice with Windows: Python: >>> import os.path >>> os.path.join("directory","file") 'directory\\file' JVM using Groovy groovy> println new File("directory", "file").getPath(); directory\file .Net using C# class Demo { public static void Main() { System.Console.WriteLine (System.IO.Path.Combine("directory", "file")); } } Output: directory\file |
So the Go language designers know better than the Windows developers what we are supposed to write when targeting Windows?! Please take time to read Microsoft documentation before saying that the applications are broken, http://msdn.microsoft.com/en-us/library/aa365247%28v=VS.85%29.aspx Take also time to read that UNC paths do not accept forward slashes. If Go is to be used by Windows developers, then please take time to follow the right conventions. When I created this issue, I was planning to provide the patch myself, but on the light of the current discussion, I fear my work won't be appreciated at all. |
I agree that directory\file form is used on Windows most of the time, but all APIs I've used do work with directory/file as well. Perhaps you would like to tell us why you have to have your path '\' delimited, so we can understand what your problem is and try to help you. Having single form that can be used on both Unix and Windows simplify things a bit. If you would like to offer a change to have '\' as path separator on Windows, please go ahead, but it would have to be simple enough. |
I am not happy about making this change. It means anyone using path to manipulate /-separated things like URL paths will have their code break on Windows. I don't want Go programs generating things like http://www.google.com\codesearch. Yuck. Owner changed to r...@golang.org. Status changed to Thinking. |
Issue #1422 has been merged into this issue. |
That is exactly the reason why, usually Windows developers don't use path APIs to deal with URLs. They are not handled the same way as file systems paths. The reason I want to use '\' is because, *again*, even though the Win32 API supports them, they are not handled correctly by most applications. If I need to generate pathnames that are given to other Windows applications I need to code them by hand, losing the benefit to use the path package. Plus if I need to handle UNC paths, I am also required to generate the paths without help from the path package. I really don't understand why Go does not follow what every programming language on WIndows offers and what Microsoft's own documentation suggests. But maybe Windows is not that important anyhow... |
I strongly suggest breaking out the path into a URL path handler that knows about protocols, and a file path handler that knows about rooting and normal OS slashes. Reasons: A) not all APIs accept '/', example: http://msdn.microsoft.com/en-us/library/aa365247(v=vs.85).aspx Note File I/O functions in the Windows API convert "/" to "\" as part of converting the name to an NT-style name, except when using the "\\?\" prefix as detailed in the following sections. In modern file system/apps on windows, \\?\ is becoming more common. B) I can state from experience, when I was in high school and open source programs were first being ported to windows, many such programs used '/' slashes for a dir sep. This confused me. I've now gone to college, graduated and work with many different clients (I'm a contractor) and although I now use Linux as my primary workstation and understand why it technically works in most cases, as a contractor if a feature bothers a client (and this would), I fix it even when it's a pain to do given the existing framework. So this is really a selfish request, I want to work with a library, not around it. |
I recall with darcs having to work around programs (putty?) that require backslashes in their file path arguments, and it definitely seems worth having a package to do this. Also, windows has a horrid mash of other path types (e.g. relative to the working directory on a different drive) and it'd be nice to have functionality to handle those paths as well. Perhaps we could gain an os.path, which would be mostly reexporting path on unixy machines, but would handle windows paths natively? |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by paulo.jpinto:
The text was updated successfully, but these errors were encountered: