3 ms·
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
by tredre3 3y ago
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/naming-a-file?redirectedfrom=MSDN#win32-file-namespaces 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.