While opening my Go project in VSCode or using the Go: install/update tools command I am getting the following error:

1 tools failed to install.

gopls: failed to install gopls(golang.org/x/tools/gopls@latest): Error: Command failed: /usr/local/bin/go install -v golang.org/x/tools/gopls@latest
go: downloading golang.org/x/sys v0.1.0
../../pkg/mod/golang.org/x/[email protected]/go/packages/external.go:15:2: golang.org/x/[email protected]: read "https:/proxy.golang.org/@v/v0.1.0.zip": stream error: stream ID 9; NO_ERROR; received from peer

GOPATH is set properly (other tools were installed successfully).

Versions:

  • VSCode: 1.73.1
  • Golang: 1.19.3.
2

There are 2 answers

0
Saikat On

Found a workaround:

I updated the GOPROXY environment variable:

export GOPROXY="direct"

It started working after that.

Maybe some network issue within my company proxy was causing this in the first place.

Note: Add the statement to your respective shell profile to make this change permanent.

0
Edward Casanova On

Genius!

I was facing the following error while running:

go install -v golang.org/x/tools/gopls@latest

go: downloading golang.org/x/tools v0.8.0
go: downloading golang.org/x/tools/gopls v0.11.0
go: golang.org/x/tools/gopls@latest: golang.org/x/tools/[email protected]: Get "https://proxy.golang.org/golang.org/x/tools/gopls/@v/v0.11.0.zip": read tcp [2806:101e:7:d0fa:50f3:9273:e1c7:b8ce]:53301->[2607:f8b0:4007:809::2011]:443: wsarecv: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.go install -v golang.org/x/tools/gopls@latest
go: downloading golang.org/x/tools v0.8.0
go: downloading golang.org/x/tools/gopls v0.11.0
go: golang.org/x/tools/gopls@latest: golang.org/x/tools/[email protected]: Get "https://proxy.golang.org/golang.org/x/tools/gopls/@v/v0.11.0.zip": read tcp [2806:101e:7:d0fa:50f3:9273:e1c7:b8ce]:53301->[2607:f8b0:4007:809::2011]:443: wsarecv: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

Did the following on Windows Powershell

Set-Item Env:GOPROXY "direct"

And boom, solved!

Thank you!