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.待统计

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

相关推荐
天南星8 分钟前
java-WebSocket在Java生态中的发展历程
java·后端·websocket
工藤学编程34 分钟前
分库分表之实战-sharding-JDBC绑定表配置实战
数据库·分布式·后端·sql·mysql
楼田莉子42 分钟前
数据学习之队列
c语言·开发语言·数据结构·学习·算法
写不出来就跑路43 分钟前
SpringBoot静态资源与缓存配置全解析
java·开发语言·spring boot·spring·springboot
我命由我1234544 分钟前
Vue 开发问题:Missing required prop: “value“
开发语言·前端·javascript·vue.js·前端框架·ecmascript·js
企鹅侠客1 小时前
Bash与Zsh与Fish:在Linux中你应该使用哪个Shell
linux·开发语言·bash·zsh·fish
fmvrj342021 小时前
云原生:数字化转型的核心引擎
后端
RAY_01041 小时前
Python—数据容器
开发语言·python
June bug1 小时前
【python基础】python和pycharm的下载与安装
开发语言·python·pycharm
码出极致1 小时前
Redisson分布式缓存与数据一致性保障
后端