'Why cannot find declaration to go to in IntelliJ Idea?

I have a code in go, and I am using IntelliJIdea for development. 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. It shows me a lot of 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.

I am attaching the screenshot as that will be better for understanding.

See the conductor.Start(). This function is right there in the package app. 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.



Solution 1:[1]

I'm using Gogland, which is also a JetBrains IDE, but I also had a problem with symbols not getting resolved.

I fixed it by deleting the project's index file.

  1. Close the IDE.
  2. In your project directory, find a directory named ".idea".
  3. Delete all files with the extension ".iml" in that directory.
  4. Restart the IDE.

The project should get reindexed and symbols will be resolved.

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

Solution 2:[2]

For my case, Intellij didn't have Rust installed. I found that out while trying to create a new project (it had JAVA and other language support). As soon as I installed Rust, it worked.

Solution 3:[3]

For my case, I have 2 virtual environments, and I found that I did not set the correct environment in Pycharm. The environment I used did not include these packages. After I changed the environment, everything goes well.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rich Sutton
Solution 2 Vikas Goel
Solution 3 Jingnan Jia