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

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

相关推荐
UrSpecial4 分钟前
Linux线程
linux·开发语言·c++
郝学胜-神的一滴4 分钟前
深入浅出 C++20:新特性与实践
开发语言·c++·程序人生·算法·c++20
闪电麦坤9523 分钟前
C/C++项目练习:命令行记账本
开发语言·c++
kyle~33 分钟前
python---PyInstaller(将Python脚本打包为可执行文件)
开发语言·前端·python·qt
User:你的影子38 分钟前
WPF ItemsControl 绑定
开发语言·前端·javascript
小程序设计1 小时前
【springboot+vue】高校迎新平台管理系统(源码+文档+调试+基础修改+答疑)
vue.js·spring boot·后端
野生的编程萌新1 小时前
【C++深学日志】从0开始的C++生活
c语言·开发语言·c++·算法
海梨花1 小时前
字节一面 面经(补充版)
jvm·redis·后端·面试·juc
野生程序员y1 小时前
深入解析Spring AOP核心原理
java·后端·spring
波波烤鸭2 小时前
Spring Boot 原理与性能优化实战
spring boot·后端·性能优化