interface A {
func Add()
}
type B struct{}
func (b *B) Add()
type C struct{}
func (c *C) Add()
Who can I jump or get a list with B and C types from interface A
see :help :GoImplements.
It doesn't work for me.
There is my full example: https://github.com/korjavin/goimplements/tree/master
Because it relies on guru, you'll need to be in GOPATH mode to use it.
I tried
export GO11MODULE=off
and pwd is according to GOPATH, but it doesn't work still.
Do you mean GO111MODULE=off?
yes
echo $GO111MODULE
off
> pwd
/home/iv/Projects/go/src/github.com/korjavin/goimplements
>go env GOPATH
/home/iv/Projects/go
Can you run vim with let g:go_debug=['shell-commands'] and try again? Then take the guru command output when running :GoImplements and run it in a shell to see what the output is?
I'm sorry.
I set g:go_debug

But I can't see anything like output on :GoImplements (too fast?)
If it's too fast, you can execute :messages to see it.
Since the implementation is in another package, you'll need to set the scope (by default the guru scope for :GoImplements is set to the package of the current buffer). You can set the scope by using :GoGuruScope.
However, even without the scope set, I'd expect to see results in the quickfix window _and_ output showing the command that was run if you set g:go_debug=['shell-commands'] prior to running :GoImplements.
Messages maintainer: Bram Moolenaar <[email protected]>
"pkg1/interface.go" 5 lines, 42 characters
vim-go: job command: ['/home/iv/Projects/go/bin/gopls']
vim-go: shell command: '/usr/local/go/bin/go' 'env' 'GOMOD'
vim-go: initializing gopls
vim-go: initialized gopls
vim-go: shell command: '/usr/local/go/bin/go' 'list'
vim-go: [implements] dispatched
vim-go: job command: ['/home/iv/Projects/go/bin/guru', '-tags', '', '-scope', 'github.com/korjavin/goimplements/pkg1', 'implements', '/home/iv/Projects/go/src
/github.com/korjavin/goimplements/pkg1/interface.go:#19']
vim-go: analysing with scope github.com/korjavin/goimplements/pkg1 (see ':help go-guru-scope' if this doesn't work)...
It works now with setting guruscope.
Is it possible to set guruscope to a point where .git folder located, somehow automatically?
It wouldn't make sense to base it on a .git folder, because code doesn't just live in git repositories. We can actually remove the default scope for :GoImplements so that by default all of GOPATH will be searched, but I'm a little reluctant to do that, because the default scope for :GoImplements was added because of the performance of searching all of GOPATH for implementations.
From my point of view: code does live in git repos.
You're free to write a function that will walk up your directories to find a git repo and set the scope when you find it.
However, there are many other source control tools other than git, and many repositories are structured such that they contain a GOPATH within them, and it wouldn't make sense for vim-go add such a function, because it could end up setting the scope to a directory that's above GOPATH.
vim-go is focused on Go, not source control.
@korjavin I think we've resolved the issue that you reported, but I want to make sure you agree before I close this, because it's odd that :GoImplements wasn't working for you in your example in pkg1 at first, and it's not clear to me what you did to get it to work. Setting :GoGuruScope shouldn't be necessary in GOPATH mode to see the types that the implement an interface in the same package as the interface is defined. 馃
Setting :GoGuruScope certainly works, and it doesn't works without it.
I think we can close this one. And thank you a lot for your help.
That's really odd. In the output you provided, the scope was the default that's used by vim-go for : GoImplements.
Most helpful comment
see
:help :GoImplements.