start
I'm not a professional coder, but I like to build small tools with simple code. I don't know much about Go, and the only one tool that related to Go I ever downloaded and configured was goimapnotify, which I still use today in line with NeoMutt as an mail notifier on my macOS and Arch Linux.
I tried to install a static site generator gozzi with the following command, but kept receiving the same error:
╭╴ alowree on Arch Linux at ~
╰─❯ go install gitlab.com/tduyng/gozzi@latest
go: gitlab.com/tduyng/gozzi@latest: module gitlab.com/tduyng/gozzi: Get "https://proxy.golang.org/gitlab.com/tduyng/gozzi/@v/list": dial tcp 142.250.73.81:443: i/o timeoutWhat does this mean? What should I do next?
这个错误信息 dial tcp 142.250.73.81:443: i/o timeout 表明你的网络连接超时了。具体来说,go install 命令尝试访问默认的 Go 模块代理 proxy.golang.org 来下载 gozzi,但连接失败了。这通常是因为网络环境无法直接访问该代理服务。
🛠️ 解决方案:更换 Go 模块代理
既然原因是网络不通,最直接的解决方法就是为 Go 配置一个能稳定访问的模块代理。
更换代理:在终端中执行以下命令,将
GOPROXY环境变量设置为国内常用的代理服务https://goproxy.cn。bash╭╴ alowree on Arch Linux at ~ ╰─❯ go env -w GOPROXY=https://goproxy.cn,direct这里的
,direct是一个备选方案,表示如果代理无法获取模块,则直接从代码仓库(如 GitLab)下载。重试安装命令:完成代理设置后,再次运行之前的安装命令即可。
bash╭╴ alowree on Arch Linux at ~ ╰─❯ go install gitlab.com/tduyng/gozzi@latest go: downloading gitlab.com/tduyng/gozzi v0.1.6 go: downloading github.com/fsnotify/fsnotify v1.9.0 go: downloading golang.org/x/text v0.32.0 go: downloading github.com/BurntSushi/toml v1.5.0 go: downloading github.com/yuin/goldmark v1.7.13 go: downloading gopkg.in/yaml.v3 v3.0.1 go: downloading github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc go: downloading github.com/tdewolff/minify/v2 v2.24.8 go: downloading go.abhg.dev/goldmark/mermaid v0.6.0 go: downloading golang.org/x/sys v0.37.0 go: downloading github.com/alecthomas/chroma/v2 v2.20.0 go: downloading github.com/dlclark/regexp2 v1.11.5 go: downloading github.com/tdewolff/parse/v2 v2.8.5
设置完成后,go install 命令应该能够正常工作了。
