英文:
vscode with go extension is confused about the name of an import
问题
vscode v1.62.2. vscodego v0.29.0。
我已经成功地搞混了vscodego。
最初我在"go.mod"中为应用程序创建了一个特定的模块名称。今天我意识到我应该稍微改变一下这个名称。我在模块名称的末尾添加了两个字符。
由于我有一些模块和包,我不得不更改这些包的导入引用。对于除一个模块外,这个操作都很顺利。在其他模块中,当我在"go.mod"中更改了主模块名称后重新进入模块时,有一个带有红线的导入。我将引用中的基本模块名称更改为与我在"go.mod"中设置的新名称相匹配。这样就消除了红线。
然而,在一个模块中,发生了一些非常奇怪的事情。就像其他模块一样,这一行最初有一个红线。我更改了基本模块引用并保存。红线消失了,然后在一秒钟后重新出现,然后我悬停查看错误消息。
错误消息如下所示:
"voltagems/handlers"
无法导入voltage/handlers(没有必需的模块提供包"voltage/handlers")
明确一下,基本模块的原始名称是"voltage"。我将其更改为"voltagems"。请注意,尽管它说"voltagems/handlers"无法工作,但它说无法导入"voltage/handlers"(没有"ms")。从技术上讲,错误消息是正确的。没有"voltage/handlers"包。它是"voltagems/handlers",尽管我在导入中输入的是这个,但vscodego似乎认为我输入的是"voltage/handlers"。
有没有办法告诉vscode/vscodego重新检查项目?
英文:
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?
答案1
得分: 0
首先尝试使用命令面板,选择“重新加载窗口”(或者直接关闭并重新启动VSCode)。
检查重新加载项目(以及其依赖/包)是否会有帮助。
英文:
Try first a command palette, "Reload Windows" (or simply close and relaunch VSCode).
Check if reloading the project (and its dependencies/packages) would help.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论