简体   繁体   English

为什么在 IntelliJ Idea 中找不到 go 的声明?

[英]Why cannot find declaration to go to in IntelliJ Idea?

I have a code in go, and I am using IntelliJIdea for development.我有一个代码在go,我正在使用IntelliJIdea进行开发。 It used to work fine, but since the time I have changed the folder where the code used to be, IntelliJ has been behaving in a weird manner.它曾经工作正常,但自从我更改了代码所在的文件夹后,IntelliJ 的行为一直很奇怪。 It shows me a lot of unable to find declaration to go to errors .它向我显示了很多unable to find declaration to go to errors After changing the folder where my project used to be, I changed the GOPATH and imported from the new directory once again.更改我的项目原来所在的文件夹后,我更改了 GOPATH 并再次从新目录导入。

I am attaching the screenshot as that will be better for understanding.我附上屏幕截图,因为这样可以更好地理解。

See the conductor.Start().参见 conductor.Start()。 This function is right there in the package app.这个 function 就在 package 应用程序中。 But it can't find this.但是它找不到这个。

PS: I have tried importing the project from scratch and invalidating and restarting multiple times, but that didn't help. PS:我试过从头开始导入项目并多次失效和重启,但没有帮助。

I'm using Gogland, which is also a JetBrains IDE, but I also had a problem with symbols not getting resolved.我正在使用 Gogland,它也是一个 JetBrains IDE,但我也遇到了符号未解决的问题。

I fixed it by deleting the project's index file.我通过删除项目的索引文件来修复它。

  1. Close the IDE.关闭 IDE。
  2. In your project directory, find a directory named ".idea".在您的项目目录中,找到一个名为“.idea”的目录。
  3. Delete all files with the extension ".iml" in that directory.删除该目录中所有扩展名为“.iml”的文件。
  4. Restart the IDE.重新启动 IDE。

The project should get reindexed and symbols will be resolved.该项目应该被重新索引并且符号将被解析。

https://www.jetbrains.org/intellij/sdk/docs/basics/project_structure.html?search=.iml https://www.jetbrains.org/intellij/sdk/docs/basics/project_structure.html?search=.iml

For my case, I have 2 virtual environments, and I found that I did not set the correct environment in Pycharm.就我而言,我有 2 个虚拟环境,我发现我没有在 Pycharm 中设置正确的环境。 The environment I used did not include these packages.我使用的环境没有包含这些包。 After I changed the environment, everything goes well.我换了环境后,一切顺利。

For my case, Intellij didn't have Rust installed.就我而言,Intellij 没有安装 Rust。 I found that out while trying to create a new project (it had JAVA and other language support).我在尝试创建一个新项目时发现了这一点(它有 JAVA 和其他语言支持)。 As soon as I installed Rust, it worked.我一安装 Rust,它就起作用了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM