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

Go to definition fails the second time, when the first time is on a sub module #2296

Closed
ramya-rao-a opened this issue Jan 31, 2019 · 7 comments
Labels
go-modules Related to Go modules

Comments

@ramya-rao-a
Copy link
Contributor

Sample repo: https://github.com/kidlj/demo

  • Open the main.go file in the sub module for gin
  • Run Go to definition on any of the symbols from the context package. (This doesnt work in 0.8.0, but will work on the beta package of 0.8.1)
  • In the file that opens, run Go to definition again on any of the symbols from the context package.

This fails with the error
godef: There must be at least one package that contains the file

@ramya-rao-a
Copy link
Contributor Author

This is probably because we are using the root folder i.e the one mapping to the main module, when running the godef the second time.

At this time, all we know is the file for the which the operation is being made i.e the one from module cache. For such case, we fall back to the project root folder as the working directory. Because by this time, we have lost the context that we landed in the current file from the sub module.

@clor09
Copy link

clor09 commented Feb 15, 2019

hi, is there any plan to fix this?~ @ramya-rao-a

@ramya-rao-a
Copy link
Contributor Author

@clor09 There is no good solution at hand at the moment, ideas are welcome

@jellevandenhooff
Copy link

Does the language server protocol have some support for communicating the root? Could paths be munged somehow to give the language server an idea that we are looking at a submodule? This feature is the one holding me back from switching from gocode+vendor to gopls+modules. CC @stamblerre

@stamblerre
Copy link
Contributor

@jellevandenhooff: This should work correctly now in gopls, as the LSP does provide the module root.

@ramya-rao-a: This issue could probably be closed since modules support will be provided through gopls anyway.

@jellevandenhooff
Copy link

Yes, it totally works now! Thanks!

@ramya-rao-a
Copy link
Contributor Author

Closing this issue as the recommendation for modules is to use the language server

@vscodebot vscodebot bot locked and limited conversation to collaborators Dec 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
go-modules Related to Go modules
Projects
None yet
Development

No branches or pull requests

4 participants