Closed jmrodri closed 7 years ago
Hi @jmrodri
Can you please create a simple go package that imports the subfolder you mention? I'm not sure the problem is vim-go, we just use goimports and nothing else. Thanks
@fatih the problem is that vim-go uses fnamemodify(a:target, ":p")
which passes in the full name of the file. Now under 99% of the cases this works, except for my case because I symlink my project into the GOPATH. So fnamemodify
will return the original path of the file which is outside the GOPATH. goimports
won't work that way.
If I change vim-go to not use fnamemodify
everything works both with my project being a symlink and with my project being directly in GOPATH.
I created a PR with the fix: https://github.com/fatih/vim-go/pull/1238
Apparently the test failed, so I'll look over that.
This is now fixed in master. Thanks!
Behavior
With goimports enabled in .vimrc, a file with "github.com/op/go-logging" in its imports, saving the file will remove the import. Removing the import causes the project not to build. After much digging this only happens if the go project was SYMLINKED into the GOPATH.
Expected Behavior: When saving the file, I expect
goimports
to find the proper import and name it correctly instead of deleting it:logging "github.com/op/go-logging
Steps to reproduce:
Setup project with a symlink.
.vimrc
:let g:go_fmt_command = "goimports"
NOTICE that there is a
"github.com/op/go-logging"
import.NOTICE that the
"github.com/op/go-logging"
import was removed.Configuration
Add here your current configuration and additional information that might be useful, such as:
vimrc
you used to reproduce