go error set (continuously updated)

1. Prompt the following error report

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)
Insert image description here

Solution:

go env -w GO111MODULE=auto

2. Failed to install module

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

Insert image description here

Configure Goproxy environment variables

Bash (Linux or macOS)

export GOPROXY=https://mirrors.aliyun.com/goproxy/,direct

PowerShell (Windows)

$env:GOPROXY = "https://mirrors.aliyun.com/goproxy/,direct"

Enable Go Modules functionality

go env -w GO111MODULE=on

Make the configuration effective for a long time (recommended)
The above configuration steps will only take effect in the current terminal. How to take effect permanently, so that you don’t have to configure environment variables every time.

Mac/Linux

Set your bash environment variables

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

If your terminal is zsh, use the following command

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

Windows

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

3. To be counted

If you have any errors, you can synchronize them or leave comments in the comment area.

Guess you like

Origin blog.csdn.net/m0_55877125/article/details/132170672