Home >Backend Development >Golang >go get command stuck on 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.
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
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
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?
Based on @para's comment. I need to use go_proxy.
export goproxy=https://proxy.golang.org
But first, make sure you can open golang.org/proxy.golang.org in your browser.
Make sure your goproxy
is set
go env
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!