News for hackers. Stuff that matters.
Re:Why Does Windows Use Backslash as Path Separator? by tredre3 on Wednesday April 24, 2024 @06:45PM (#40150791)
The high level Win32 API does this to be helpful because a trailing space is usually not what the user wants. You can argue it's stupid if you want, but the OS supports files that end with dots and spaces just fine if you call the right APIs.

I guess Go hooks into too high level of an API. But you can prefix all your paths with "\\?\" to "force it" to be evaluated as is.

Consider the following program:

    package main
    import "os"
    func main() {
       os.Mkdir(os.Args[1], 0777)
    }
Invoking test.exe c:\test... will create c:\test Invoking test.exe \\?\c:\test... will create c:\test...

See: https://learn.microsoft.com/en-ca/windows/win32/fileio/namin...

The link also explains why the file path length limit and details how to disable the limit.

There are no comments on this comment yet.