I used gd on a function
I expected to go to the definition of the function
I got an error:
vim-go: [searching declaration] dispatched
vim-go: [searching declaration] FAIL
vim-go version:
vimrc you used to reproduce (use a minimal vimrc with other plugins disabled; do not link to a 2,000 line vimrc):
" Here are my plugins
call plug#begin('~/.vim/plugged')
" ~~~ Language Server ~~~
Plug 'autozimu/LanguageClient-neovim', {
\ 'branch': 'next',
\ 'do': 'bash install.sh',
\ }
" ~~~ Language support
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
" ~~~ auto completion ~~~
Plug 'Shougo/deoplete.nvim'
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
" ~~~ fuzzy finding ~~~
Plug '/usr/local/opt/fzf'
Plug 'junegunn/fzf.vim'
" ~~~ ctags ctag tag files ~~~
" https://tbaggery.com/2011/08/08/effortless-ctags-with-git.html
Plug 'ludovicchabant/vim-gutentags'
" vim-gutentags manages ctag tag files
" Initialize plugin system
call plug#end()
" Here are my vimrc mappings
" Golang and vim-go mappings
nnoremap <leader>gr :GoRun<cr>
let g:go_fmt_command = "goimports"
let g:go_def_mapping_enabled = 1
:version):VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Mar 13 2018 06:36:50)
macOS version
Included patches: 1-1600
go version):go version go1.11 darwin/amd64
go env):GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/danielburt/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/danielburt/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.11/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.11/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/1c/66mlc88x2ld7tzmm91xwljqm0000gp/T/go-build127663048=/tmp/go-build -gno-record-gcc-switches -fno-common"
It may be worth noting that I think I did my initial go install through this plugin.
gd generally works. After it fails for you, is there any useful output from :messages?
It may be worth noting that I think I did my initial go install through this plugin.
You can't install Go with vim-go. What do you mean?
The output I pasted was from :messages. So, I installed go in the past, but none of the packages like guru or anything like that. So any packages this may need were installed by this plugin. Is there any way to get a more verbose error message? I'd be happy to modify the code for it if you can tell me how.
Did you run :GoInstallBinaries? What's your $PATH?
Yeah, I ran that command, and I instantly get vim-go: installing finished!. My $PATH is: /Users/danielburt/apache-cassandra-3.11.2/bin:./bin:/Users/danielburt/bin:/Users/danielburt/.rbenv/bin:/Users/danielburt/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Postgres.app/Contents/Versions/9.4/bin:/usr/local/mysql/bin:/Users/danielburt/bin:/Users/danielburt/go/bin
Turn on some debugging messages using let g:go_debug = ['shell-commands'] and try again. Afterwards, :messages should should show you the command that was run. Is the binary in your $PATH?
Here is the :messages after adding the debug line:
vim-go: [searching declaration] dispatched
vim-go: job command: ['/Users/danielburt/go/bin/guru', 'definition', '/Users/danielburt/development/go/cards/main.go:#57']
vim-go: [searching declaration] FAIL
And do you mean guru by "the binary"?
➜ which guru
/Users/danielburt/go/bin/guru
➜ which go
/usr/local/bin/go
If it makes my path a little bit more clear. Take a look at the end of it (taken from my .zshenv):
export PATH="./bin:$HOME/bin:/Users/danielburt/.rbenv/bin:/Users/danielburt/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Postgres.app/Contents/Versions/9.4/bin:/usr/local/mysql/bin:/Users/danielburt/bin:$GOPATH/bin"
export GOPATH="$HOME/go"
What's the output of this command when run in a shell: /Users/danielburt/go/bin/guru definition /Users/danielburt/development/go/cards/main.go:#57
The output is guru: no object for identifier
It looks like your file isn't in the expected location within $GOPATH. It _should_ be $GOPATH/src/cards, not $GOPATH/cards.
So, I tried moving a copy of my /cards dir to $GOPATH/src/cards, but that didn't seem to fix it. However, I'm new to Go, and perhaps it is looking for a different directory structure. How come my files should be in $GOPATH/src/cards? I'm following a tutorial where them being in the project folder is enough if they share the same package. Also, tags do work (if this helps).
Okay, so I read How to Write Go Code and I managed to get gd to work by putting the code in $GOPATH/src/github.com/cards/. Looks like we can close this!
Thank you for your help and time debugging this with me. I appreciate it! Is there somewhere I can donate to show my appreciation for the project?
Thank you for the offer, but the best way to be show your appreciation is to be a good member of the community. Find something you love, and give back; lots of open source projects (including vim-go!) need help with documentation, issue management, contributions, and support. 😄
:GoUpdateBinaries in vim worked for me
Most helpful comment
:GoUpdateBinaries in vim worked for me