Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

"Go to Impelmentaion" can not find what types implement the interface #1545

Closed
rockmenjack opened this issue Feb 28, 2018 · 10 comments
Closed

Comments

@rockmenjack
Copy link

When trying to find who implement the interface, nothing was found, and an error is printed in debug console:

_/home/rockmen1/playground/go/guru_test/... -json implements /home/rockmen1/playground/go/guru_test/src/test_implementation/ifce.go:#30
guru: found packages my_interface (ifce.go) and my_implementation (impl.go) in /home/rockmen1/playground/go/guru_test/src/test_implementation
: Error: Command failed: /home/rockmen1/Tools/bin/guru -scope _/home/rockmen1/playground/go/guru_test/... -json implements /home/rockmen1/playground/go/guru_test/src/test_implementation/ifce.go:#30
guru: found packages my_interface (ifce.go) and my_implementation (impl.go) in /home/rockmen1/playground/go/guru_test/src/test_implementation

Steps to Reproduce:

  1. Here is a simple step to reproduce, create a simple go code layout as below:
    vscode_test
    └── src
        └── test_implementation
            └── test.go

  2. In the test.go file:

package my_interface
type foo interface {
	bar()
}
type impl int
func (i impl) bar() {
}
  1. Now try to find what implement foo interface, nothing will be found
@rockmenjack
Copy link
Author

I think "-scope" shall not be used in finding interface implementaions, when -scope is removed, guru is able to give out the correct result.

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Feb 28, 2018

I used your code. The result correctly points to the impl type

peek

Is all your code under GOPATH?

@rockmenjack
Copy link
Author

I used these two custom settings:

    "go.inferGopath": true,
    "go.toolsGopath": "~/Tools",

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Feb 28, 2018

The fact that in your logs the file paths are preceded by _ tells me that this a GOPATH issue

I can repro something similar if I open the GOPATH directly in VS Code.

In your case, GOPATH seems to be /home/rockmen1/playground/go/guru_test
The file seems to be in /home/rockmen1/playground/go/guru_test/src/test_implementation/ifce.go
What is the folder that you have opened in VS Code?
Can you open /home/rockmen1/playground/go/guru_test/src/test_implementation and try again?

@rockmenjack
Copy link
Author

rockmenjack commented Feb 28, 2018

What is the folder that you have opened in VS Code?

It was opened at /home/rockmen1/playground/go/guru_test/

Can you open /home/rockmen1/playground/go/guru_test/src/test_implementation and try again?

It works in this case. But src/test_implementation is not actually a formal GOPATH.
I've tried open /home/rockmen1/playground/go/guru_test/src/ as well, did not work.

@kron4eg
Copy link

kron4eg commented Feb 28, 2018

@rockmenjack this very much looks like #1536 (now fixed in master)

@ramya-rao-a
Copy link
Contributor

@kron4eg This is not the same as #1536. This only occurs when GOPATH is directly opened in VS Code. The way we calculate scope gets messed up in this case.

@ramya-rao-a
Copy link
Contributor

Fixed. Need some help testing though. All you need to do is

@rockmenjack
Copy link
Author

Tried with the provided extension, it worked!

@ramya-rao-a
Copy link
Contributor

This fix is now available in the latest update (0.6.78) to the Go extension

@vscodebot vscodebot bot locked and limited conversation to collaborators Apr 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants