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

Path to modules is cached at startup and never updated #2388

Closed
alloro opened this issue Mar 19, 2019 · 4 comments
Closed

Path to modules is cached at startup and never updated #2388

alloro opened this issue Mar 19, 2019 · 4 comments
Labels
go-modules Related to Go modules needs more info upstream-gopls Issue for gopls

Comments

@alloro
Copy link

alloro commented Mar 19, 2019

In a project that uses go modules, vscode caches the paths to each library that is specified in the go.mod file on startup. When altering the go.mod file by e.g. go get the cache is not updated. Meaning that on lookup (e.g. go to definition) you'll be directed to the old path/library.
Only after a restart of the editor it'll be reloaded -- because it's always doing it on startup only as mentioned.

Steps to Reproduce:

  1. Create a go project that relies on modules and is outside of your GOPATH
  2. Lookup the implementation for one specific library (if you have breadcrumbs enabled you can see the path to the version)
  3. Downgrade the library via go get <lib path>@<version>
  4. Do a lookup again
  5. You should see the previous implementation (if you have breadcrumbs enabled you can see the path to the version)

Possible Section in the Code

To mention:

  • tried it with and without LSP (language server), to make sure that it is not a language server issue
@ramya-rao-a
Copy link
Contributor

Thanks for reporting @alloro and apologies for the delay in responding.

The extension caches 2 maps related to modules.

  • Folder of the file opened in VS Code -> Path to the go.mod file for the package in this folder
  • Folder of the file opened in VS Code -> Import path to the package in this folder

We do not cache the paths to each library in the go.mod file

Therefore, it looks like the problem is with the tool used for doing the lookup.
If you are not using the language server, then the tool that gets used is godef

Can you run the Go: Install/Update Tools , select godef and gopls , press Ok to update them and try again both with and without the language server? If you still see the issue then we need to redirect the issue to godef/gopls
The key is the folder path of the file that was opened in VS Code. The value is the path to the go.mod file

@ramya-rao-a
Copy link
Contributor

cc @stamblerre

@stamblerre
Copy link
Contributor

gopls does not yet actually handle the contents of go.mod files, so when your go.mod file changes, we do not update our caches. This is tracked upstream here: golang/go#31999.

@ramya-rao-a
Copy link
Contributor

Thanks @stamblerre
Closing this issue in favor of the upstream issue

@ramya-rao-a ramya-rao-a added go-modules Related to Go modules upstream-gopls Issue for gopls labels Jul 10, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Aug 24, 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 needs more info upstream-gopls Issue for gopls
Projects
None yet
Development

No branches or pull requests

3 participants