安装go使用命令行安装快

本文最后更新于 2026年1月13日。

直接官网下载很容易失败,速度慢

镜像网站也不行

命令行安装很快

winget install GoLang.Go --accept-package-agreements --accept-source-agreements

安装后验证环境变量

$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User"); go version
(TraeAI-3) E:\mydoc\mygit\alistserver [0:0] $ $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User"); go version
go version go1.25.5 windows/amd64

运行项目

go run main.go server

避免依赖下载失败,必须配置国内镜像:

bash

go env -w GOPROXY=https://goproxy.cn,direct  # 七牛云镜像
# 或阿里云镜像:https://mirrors.aliyun.com/goproxy/,direct