为Windows XP编译Golang 1.24代码
Go-legacy-winxp: Compile Golang 1.24 code for Windows XP

原始链接: https://github.com/syncguy/go-legacy-winxp/tree/winxp-compat

## go-legacy-win7:为遗留系统设计的Go分支 `go-legacy-win7` 是Go编程语言的一个分支,专门设计用于维护与Windows 7和Windows Server 2008 R2的兼容性——这些操作系统不再受官方Go项目支持。它还恢复了传统的`go get`工作流程,即使启用了模块,也能在GOPATH模式下运行。 该分支通过撤销在旧版Windows上破坏功能的更改来实现兼容性,包括调整随机数生成、库加载、套接字系统调用、控制台处理和进程等待。 它包含了来自上游Go发布的全部改进和错误修复,同时优先考虑遗留支持。安装涉及下载预构建的二进制文件(Windows)或归档文件(macOS/Linux),并相应地配置环境变量(GOROOT、GOPATH、PATH)。 该项目欢迎贡献,并鼓励用户报告问题和提交拉取请求。对于需要在旧版Windows基础设施上构建和维护Go应用程序的开发人员来说,这是一个宝贵的资源。

## Windows XP 仍然拥有社区 最近的 Hacker News 讨论强调了一个令人惊讶的活跃社区,他们正在维持 Windows XP 的运行。用户不仅在维护安全补丁和 MyPal 等浏览器,还在为 Discord 等平台创建现代客户端。 原因各异:一些人认为可以节省成本,但许多人指出对较新 Windows 版本臃肿和缺乏对用户尊重的做法不满。怀旧情绪也扮演着重要角色,XP 代表了许多人的 formative 计算体验。另一些人则 просто 享受维护旧系统的挑战,将其比作复古计算爱好。 有趣的是,现代开发工具*可以*针对 XP。W64devkit 提供了一个最新的 GCC 编译器,甚至像 Nim 和 C++ 这样的较新语言也可以通过一些努力为该操作系统编译。该讨论还揭示了在 XP 上运行 .NET 10 的项目。虽然属于小众,但保持 XP 运行的奉献精神表明了人们对控制、熟悉度和拒绝计划报废的渴望。
相关文章

原文

go-legacy-win7 is a fork of the Go programming language that maintains support for Windows 7 and Windows Server 2008 R2, and allows for deprecated go get behaviour. This project aims to provide a stable Go environment for users who need to support legacy Windows systems or prefer the traditional Go workflow.

Gopher image Gopher image by Renee French, licensed under Creative Commons 4.0 Attribution licence.

Differences from Upstream Go

  1. Windows 7 and Windows Server 2008 R2 Support
    While the official Go project has dropped support for Windows 7 and Windows Server 2008 R2, this fork maintains compatibility with these legacy Windows systems.

  2. Classic go get Behaviour
    This fork allows for the deprecated go get behaviour when GO111MODULE is set to "off" or "auto". This means:

    • In GOPATH/src, go get and go install can operate in GOPATH mode.
    • Outside of GOPATH/src, these commands can use module-aware mode when appropriate.
  3. Compatibility Notes
    Please be aware that some newer Go features may not be fully compatible with Windows 7 or Windows Server 2008 R2. We try to maintain as much functionality as possible, but some limitations may exist.

Every release includes the following modifications:

  • Switched back to RtlGenRandom from ProcessPrng, which breaks Win7/2008R2 (reverted 693def1)
  • Added back LoadLibraryA fallback to load system libraries (reverted a17d959)
  • Added back sysSocket fallback for socket syscalls (reverted 7c1157f)
  • Added back Windows 7 console handle workaround (reverted 48042aa)
  • Added back 5ms sleep on Windows 7/8 in (*Process).Wait (reverted f0894a0)
  • Restored deprecated go get behavior for use outside modules (reverted de4d503)
  • Includes all improvements and bug fixes from the corresponding upstream Go release

The Windows binary provided here also supports Windows 7 and Windows Server 2008 R2

Binary distributions are available at the release page.

  1. Download the go-legacy-win7-<version>.windows_<arch>.zip file.
  2. Extract the ZIP to C:\ (or any preferred location). This will create a go-legacy-win7 folder.
  3. Add the following to your system environment variables:
    • Add C:\go-legacy-win7\bin (or your chosen path) to the system PATH.
    • Set GOROOT to C:\go-legacy-win7 (or your chosen path).
  4. Add the following to your user environment variables:
    • Add %USERPROFILE%\go\bin to the user PATH.
    • Set GOPATH to %USERPROFILE%\go.

macOS and Linux Installation

  1. Download the appropriate go-legacy-win7-<version>.<os>_<arch>.tar.gz file.

    • For macOS: go-legacy-win7-<version>.darwin_<arch>.tar.gz
    • For Linux: go-legacy-win7-<version>.linux_<arch>.tar.gz
  2. Extract the archive to /usr/local:

    sudo tar -C /usr/local -xzf go-legacy-win7-<version>.<os>_<arch>.tar.gz
    
  3. Add the following to your shell configuration file:

    • For bash, add to ~/.bash_profile or ~/.bashrc
    • For zsh, add to ~/.zshrc
    export GOROOT=/usr/local/go-legacy-win7
    export GOPATH=$HOME/go
    export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
  4. Apply the changes:

    • For bash: source ~/.bash_profile or source ~/.bashrc
    • For zsh: source ~/.zshrc

    Note:

    • On macOS Catalina and later, zsh is the default shell.
    • On most Linux distributions, bash is the default shell.

After installation, verify the installation by opening a new terminal and running:

To install from source, please follow the steps on the official website.

Feedback and issue reports are welcome, and we encourage you to open pull requests to contribute to the project. We appreciate your help!

Note that the Go project uses the issue tracker for bug reports and proposals only. See https://go.dev/wiki/Questions for a list of places to ask questions about the Go language.

联系我们 contact @ memedata.com