Reputation: 323
When I try to install the Go Extension in my Visual Studio Code, and I got these error messages as below. Am I missing something here?
gocode
gopkgs
go-outline
go-symbols
guru
gorename
godef
goreturns
golint
dlv
Installing github.com/nsf/gocode FAILED
Installing github.com/uudashr/gopkgs/cmd/gopkgs FAILED
Installing github.com/ramya-rao-a/go-outline FAILED
Installing github.com/acroca/go-symbols FAILED
Installing golang.org/x/tools/cmd/guru FAILED
Installing golang.org/x/tools/cmd/gorename FAILED
Installing github.com/rogpeppe/godef FAILED
Installing github.com/sqs/goreturns FAILED
Installing github.com/golang/lint/golint FAILED
Installing github.com/derekparker/delve/cmd/dlv FAILED
10 tools failed to install.
gocode:
Error: Command failed: /usr/local/go/bin/go get -u -v github.com/nsf/gocode
package github.com/nsf/gocode: cannot download, /home/bitnumbers/go is a GOROOT, not a GOPATH. For more details see: 'go help gopath'
package github.com/nsf/gocode: cannot download, /home/bitnumbers/go is a GOROOT, not a GOPATH. For more details see: 'go help gopath'
Please advice.
Upvotes: 1
Views: 19579
Reputation: 868
I removed all old Visual Studio Code in mac. I installed latest Visual studio code and it solved the issue. https://code.visualstudio.com/docs/setup/mac
This is my .bashrc and .bash_profile setting:
export GOPATH=/Users/user/work
export GOROOT=/usr/local/Cellar/go/1.15.7/libexec
export PATH=$PATH:$GOROOT/bin
Upvotes: 0
Reputation: 2824
As you have pointed out in your comment, on your system
echo $GOPATH
and echo $GOROOT
produce empty output. This indicates an incomplete installation of go
. Now, assuming you have installed the go
toolchain via the downloads on the website or better yet, gvm
, the all there is left to do is make the environment persist the changes across terminal sessions.
Adding
export GOPATH=*your path to GOPATH*
export GOROOT=*path to your go installation*
to your ~/.bashrc
, restarting terminal session, restarting VSCode and reattempting to install the tools should do the trick.
Further reading:
https://golang.org/doc/install#install
https://github.com/golang/go/wiki/GOPATH
https://golang.org/doc/code.html#GOPATH
Upvotes: 5