The Goland package is imported normally, but the function and member attributes cannot be parsed, and the compilation does not report an error

During this time, a problem suddenly appeared in Goland. After each go get dependency, although the dependency was pulled down, its members and attributes could not be referenced in the place where the module was used in the code. The red mark in the large area would prompt "Unresolved reference 'xxxxx'".

I originally wanted to see if there was any one-and-done solution, modifying the configuration so that this problem would not occur in the future, but after reading a circle of blogs, I also asked chatgpt, and even reinstalled Goland, but I still couldn’t find a one-time solution .

Later, I fiddled with the configuration casually, and found that following the steps below can trigger the module re-index of the current project without restarting the project. Although this problem is fundamentally solved, it is finally unnecessary to restart the project every time.

1. Click the project name with the mouse to select the current project

2. Click "File -> Repair IDE"

At the bottom of Goland, you can see that Goland has started to refresh the indexable files in the selected file

3. Then a prompt box will appear in the lower right corner of Goland, "Recovery step 1: 'Refresh Indexable Files' was performed", the translation is "Recovery step 1: "Refresh Indexable Files" was performed", continue to click "Rescan Project Indexes", and the index of the project will be rescanned

At this time, Goland will re-scan all the indexes, and the problem should be solved at this time, and you will find that the original red code has returned to normal.

4. A small pop-up window will still pop up in the lower right corner of Goland, indicating that the second step of the recovery process has been executed, whether it has returned to normal, and whether it needs to re-project. If it has returned to normal, click "Everything Works Now" and it will be OK, otherwise click "Reopen Project", and then continue to look down

After restarting the project, a pop-up window appears in the lower right corner of Goland asking whether it needs to be restored to normal and whether the shared index needs to be deleted. You can check whether the import problem of the project has returned to normal. If it returns to normal, click "Everything Works Now", otherwise click "Drop shared index"

After clicking "Drop shared index", continue to "Reindex Project" in the pop-up window in the lower right corner of Goland. It should be back to normal here. If it is still not normal, you can try other tutorials, such as this: The goland package is imported normally, but all methods cannot be parsed and compiled without error

Guess you like

Origin blog.csdn.net/qq_41767116/article/details/131161195