When GoImports is set to run when the file is saved (or perhaps more accurately, when GoFmt is run), vim-go complains with the following: "vim-go: goimports does not support srcdir." and the file is cleared and overwritten.
I have run :GoUpdateBinaries, but the problem persists.
GoImports would function normally without the error message, or at least not clear the file when it fails.
let g:go_fmt_command = "goimports" to your .vimrc so that GoImports is triggered on save.:wvimrc you used to reproducesyntax on
call pathogen#infect()
call pathogen#helptags()
" vim-go configuration
let g:go_fmt_command = "goimports"
Hi @velovix
What happens if you run goimports --help from the terminal? I think it seems like you still have the old one. In the flags you should see the -srcdir flag, if that is not the case, you still have the old one.
Results of goimports --help:
$ goimports --help
usage: goimports [flags] [path ...]
-d display diffs instead of rewriting files
-e report all errors (not just the first 10 on different lines)
-l list files whose formatting differs from goimport's
-srcdir dir
choose imports as if source code is from dir
-w write result to (source) file instead of stdout
It looks like I'm up to date.
What gives this ex command when you execute it from inside vim:
:echo system("goimports --help")
:echo system("which goimports")
And from your terminal:
which goimports
Seems like your Vim picks up an old version somehow. This is not something I can reproduce, let's see if we can find something.
It looks like this wasn't an issue with vim-go after all. I found that any echo system() command would print nothing, so after some messing around, I decided to reinstall vim and now everything seems to be working fine again. I have no idea what happened, but I suspect that while I was experimenting with neovim, I must have messed up something. I can't seem to reproduce it, though. Thanks for working this through with me and sorry for the noise!
I just had the same issue and was able to reproduce it. The symptom happens when I am using tmux.
OS: mac os x El Capitan
I ran into this problem, too. My issue was apparently that $GOPATH/bin was not in PATH. (How vim-go managed to find a version of goimport, however outdated, I'm not sure.) Once I set export PATH=$PATH:$GOPATH/bin in .bashrc, everything worked fine.
I ran into this issue as well, but was able to fix it by running :GoUpdateBinaries
Most helpful comment
I ran into this problem, too. My issue was apparently that
$GOPATH/binwas not in PATH. (How vim-go managed to find a version of goimport, however outdated, I'm not sure.) Once I setexport PATH=$PATH:$GOPATH/binin.bashrc, everything worked fine.