Skip to content

os: investigate dropping support for pre-long-path Windows #69853

Open
@neild

Description

@neild

On Windows, the os package includes some trickery to enable support for long paths on older versions of Windows. The fixLongPath function rewrites longer paths to contain a \\?\ prefix, which "tells the Windows APIs to disable all string parsing and to send the string that follows it straight to the file system." (https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#win32-file-namespaces)

The \\?\ prefix can have effects other than just making a longer path work. For example, Mkdir(`\\?\c:\foo `) will create a directory "foo " with a trailing space, while Mkdir(`c:\foo `) will strip the space and create "foo".

Newer versions of Windows optionally support long paths directly. On Windows 10.0 with a build ID of 15063 and higher, we skip the \\?\ workaround: https://go.googlesource.com/go/+/refs/tags/go1.23.0/src/runtime/os_windows.go#450

Interestingly, the Windows documentation indicates that long paths should be supported on 10.0.1607 and higher
(https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry#enable-long-paths-in-windows-10-version-1607-and-later), and 1607 is build id 14393 (https://learn.microsoft.com/en-us/windows/release-health/release-information).

I don't know why we're checking for a build ID of 15063 instead of 14393.

https://go.dev/wiki/MinimumRequirements#windowswindows says that the supported Windows versions are Windows 10 and higher or Windows Server 2016 and higher.

I don't know what versions of Windows Server 2016 support long paths.

Do we still support any versions of Windows that don't have long path support? Can we just drop the \\?\ workaround entirely?

/cc @qmuntal

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.OS-Windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions