go get command stuck on Mac

WBOY
Release: 2024-02-09 19:18:08
forward
990 people have browsed it

go get 命令在 Mac 上卡住

php editor Zimo found that you may encounter stucks when using the go get command on the Mac operating system. This issue may be due to network issues or incorrect proxy settings. To solve this problem, you can try the following methods: check the network connection, switch to a domestic mirror source, or use a proxy tool. These methods help solve the problem of the go get command getting stuck on Mac, allowing developers to smoothly use the go language for development work.

Question content

I am trying to install some libraries in golang. But when I run go get [package] it always gets stuck. Errors vary. One of them is this:

➜  alif git:(master) ✗ go get "github.com/go-playground/validator/v10"
go: downloading github.com/go-playground/validator/v10 v10.11.2
go: downloading github.com/go-playground/validator v9.31.0+incompatible
go: github.com/go-playground/validator/[email protected]: read "https:/proxy.golang.org/@v/v10.11.2.zip": read tcp 192.164.0.2:58505->34.101.4.81:443: read: connection reset by peer
Copy after login

Sometimes the connection is refused or times out.

➜  alif git:(master) ✗ go get "github.com/go-playground/validator/v10"
go: downloading github.com/go-playground/validator/v10 v10.11.2
go: downloading github.com/go-playground/validator v9.31.0+incompatible
go: golang.org/x/[email protected]: verifying go.mod: golang.org/x/[email protected]/go.mod: Get "https://sum.golang.org/lookup/golang.org/x/[email protected]": net/http: TLS handshake timeout
Copy after login

My network is working fine. In fact, just like two days ago, I had no problem downloading the go dependencies.

My go version is go1.19, I tried to upgrade to go1.20 but the problem still occurs. I'm using macos m1. what can I do?

Solution

Based on @para's comment. I need to use go_proxy.

export goproxy=https://proxy.golang.org
Copy after login

But first, make sure you can open golang.org/proxy.golang.org in your browser.

Make sure your goproxy is set

by checking go env with this command
go env
Copy after login

The above is the detailed content of go get command stuck on Mac. For more information, please follow other related articles on the PHP Chinese website!

source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!