Home > Mobile >  vscode with go extension is confused about the name of an import
vscode with go extension is confused about the name of an import

Time:11-13

vscode v1.62.2. vscodego v0.29.0.

I have managed to confused vscodego.

I had initially created the app with a particular module name in "go.mod". Today I realized I should change the name slightly. I added two characters to the end of the module name.

As I have a handful of modules and packages, I had to change the import reference for those packages. This worked perfectly fine for all but one module. On the others, when I reentered the module after changing the main module name in "go.mod", there was an import with a red line under it. I changed the base module name in the reference to match the new name I set in "go.mod". That got rid of the red line.

However, in one module, something really odd is happening. Just like the other modules, the line initially had the red line. I changed the base module reference and saved. The red line went away, then after a second reappeared, and then I hovered to see the error message.

This is what it said:

"voltagems/handlers"
could not import voltage/handlers (no required module provides package "voltage/handlers")

To be clear, the original name of the base module was "voltage". I changed it to "voltagems". Notice that although it says that "voltagems/handlers" is not working, it's saying that "voltage/handlers" (without the "ms") cannot be imported. The error message taken on its own is technically correct. There is no "voltage/handlers" package. It is "voltagems/handlers", and even though that's what I'm typing in the import, vscodego seems to think I typed "voltage/handlers".

Is there some way to tell vscode/vscodego to reexamine the project?

CodePudding user response:

Try first a command palette, "Reload Windows" (or simply close and relaunch VSCode).

Check if reloading the project (and its dependencies/packages) would help.

  • Related