vim-go: could not find 'gopls'

Viewed 2940

After installing Plug 'fatih/vim-go' Plugin for golang i get few errors

steps: When opening .go file with vim I get a error:

vim-go: could not find 'gopls' . Run :GoInstallBinaries to fix it
vim-go: could not determine appropriate working directory for go plus

When doing :GoInstallBinaries I get more errors like:

vim-go: guru not found. instaling golang.org..guru@master to folder C:\Users\*MYPC*\go\bin\
vim-go: Error instaling golang.org/x/tools/cmdfuru@master: The system cannot find the path specified.
vim-go: goplus not found. instaling golang.org..goplus@latest to folder C:\Users\*MYPC*\go\bin\
vim-go: Error instaling golang.org..goplus@latest: The system cannot find the path specified.
.
.
.
it does that 8 more times with godef,motion,errcheck,dlv,iferr,golint...

When i do :echo $PATH in Vim i have C:\Users*MYPC*\go\bin\

I am running gvim on Windows 10

golang in cmd or powershell work fine...

4 Answers

Just run go get golang.org/x/tools/gopls@latest, and problem solved!

In the vim-go setup instructions, there's a detail about running :GoInstallBinaries in vim after install. You probably missed it (I ran into this issue after I upgraded to a new go runtime)

Answer for WSL (Windows subsystem for Linux):

I tried to installed gopls manually, running go get golang.org/x/tools/gopls@latest but I was getting the following error:

XXXX@XXXX:~$ go get golang.org/x/tools/gopls@latest
go: can only use path@version syntax with 'go get' and 'go install' in module-aware mode

Changing the Go mode fixed the problem at this stage GO111MODULE=on, then I could run

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

However, later on, when vim-go was trying to install the missing packages after running GoInstallBinaries I was getting errors that I couldn't use versions with go install. So what I did was reinstall Go (the latest version) on the system using these instructions. After doing that, vim-go was able to install the packages. I hope this answer saves time for future vim-go enthusiasts.

for mac was solved with

brew install gopls
Related