Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/go: lowercase package directory comparison is wrong #25878
https://golang.org/cl/109235 changed the meaning of directory patterns to do case-insensitive matches on Windows. This is not correct behavior. Maybe it is slightly more correct than not, but it's still wrong. I believe that Windows can have case-sensitive file systems, and certainly there are other systems with case-insensitive file systems (most Macs, for example). The general solution can't be to use strings.EqualFold based on runtime.GOOS.
I suspect the answer is to do something like
but I am not sure whether os.SameFile works on directories on Windows.
Does anyone know?
send reply to the issue:
Why CL 109235 is not correct behavior? Do you know of a setup where TestCDAndGOPATHAreDifferent fails?
I did some experiment at home. I have Linux computer that runs Samba software, that allows some Linux directories accessible to Windows computers on the network. so I created directory with 2 sub-directories having same name, just different case, and have different contents. Just like:
And then I mounted that directory on my Windows computer. That is what I see:
cmd.exe uses same API as Go programs do, so Go programs will see exactly the same thing.
Something https://blogs.msdn.microsoft.com/commandline/2018/02/28/per-directory-case-sensitivity-and-wsl/ I have found while googling for this issue. Perhaps it is related.
The original CL 109235 was addressing a real bug (in its commit message) but the problem is not that the pattern match algorithm was wrong. The problem is that the pattern going into the match was wrong. Bad inputs not bad outputs. I'll take a look at an alternate fix for that real issue.