go错误集(持续更新)

1.提示以下报错

Build Error: go build -o c:\Users\Administrator\Desktop__debug_bin2343731882.exe -gcflags all=-N -l .

go: go.mod file not found in current directory or any parent directory; see 'go help modules' (exit status 1)

解决办法:

bash 复制代码
go env -w GO111MODULE=auto

2.安装模块失败

dlv: failed to install dlv(github.com/go-delve/delve/cmd/dlv@latest): Error

解决办法:

配置 Goproxy 环境变量

Bash (Linux or macOS)

bash 复制代码
export GOPROXY=https://mirrors.aliyun.com/goproxy/,direct

PowerShell (Windows)

bash 复制代码
$env:GOPROXY = "https://mirrors.aliyun.com/goproxy/,direct"

启用 Go Modules 功能

bash 复制代码
go env -w GO111MODULE=on

使配置长久生效 (推荐)

上面的配置步骤只会当次终端内生效,如何长久生效呢,这样就不用每次都去配置环境变量了。

Mac/Linux

设置你的 bash 环境变量

bash 复制代码
echo "export GOPROXY=https://mirrors.aliyun.com/goproxy/,direct" >> ~/.profile && source ~/.profile

如果你的终端是 zsh,使用以下命令

bash 复制代码
echo "export GOPROXY=https://mirrors.aliyun.com/goproxy/,direct" >> ~/.zshrc && source ~/.zshrc

Windows

bash 复制代码
1. 右键 我的电脑 -> 属性 -> 高级系统设置 -> 环境变量
2. 在 "[你的用户名]的用户变量" 中点击 "新建" 按钮
3. 在 "变量名" 输入框并新增 "GOPROXY"
4. 在对应的 "变量值" 输入框中新增 "https://mirrors.aliyun.com/goproxy/,direct"
5. 最后点击 "确定" 按钮保存设置

3.待统计

各位大佬有错误集也可同步或在评论区中评论。

相关推荐
杨凯凡1 天前
Spring Boot SSE 上线后不实时、频繁断线?Nginx 缓冲、心跳与连接回收实战
spring boot·后端·nginx
锋行天下1 天前
langgraph 全栈项目(三)
前端·人工智能·后端
金銀銅鐵1 天前
用 Swing 重做操作数栈演示
java·jvm·后端
琳少_1 天前
java程序开发笔记
java·开发语言·数据库·笔记
锋行天下1 天前
langgraph 全栈项目(二)
前端·人工智能·后端
七夜zippoe1 天前
Agent 告警设计:分级告警、智能降噪与值班排班
开发语言·ai·agent·告警·智能降噪·值班排班
锋行天下1 天前
langgraph全栈项目(一)
前端·人工智能·后端
学长毕设1 天前
基于SpringBoot的游戏攻略社区交流系统-附源码
spring boot·后端·游戏
程序员cxuan1 天前
不得了,Google 造反了,Opus 5.5 又被干了
人工智能·后端·程序员
严肃小白兔1 天前
PHP 8.6 正式发布:部分函数应用、原生 I/O 轮询与新特性实战解析
开发语言·php