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 小时前
设计模式有哪几类?
前端·后端·设计模式
Yeats_Liao1 小时前
Go Web 编程快速入门 10 - 数据库集成与ORM:连接池、查询优化与事务管理
前端·数据库·后端·golang
千里镜宵烛1 小时前
Lua-迭代器
开发语言·junit·lua
渡我白衣2 小时前
C++ 同名全局变量:当符号在链接器中“相遇”
开发语言·c++·人工智能·深度学习·microsoft·语言模型·人机交互
淮北4942 小时前
html + css +js
开发语言·前端·javascript·css·html
你的人类朋友2 小时前
适配器模式:适配就完事了bro!
前端·后端·设计模式
间彧2 小时前
SpringBoot集成RocketMQ事务消息
后端
源码_V_saaskw3 小时前
JAVA国际版二手交易系统手机回收好物回收发布闲置商品系统源码支持APP+H5
java·开发语言·微信·智能手机·微信小程序·小程序
java1234_小锋3 小时前
PyTorch2 Python深度学习 - PyTorch2安装与环境配置
开发语言·python·深度学习·pytorch2