Valid methods in being highlighted in red 'Unresolved Reference'

11,042

Solution 1

The methods are defined in a big generated file that is not indexed by Gogland. To change the limit you should change idea.max.intellisense.filesize.

To do this, open custom properties file via Help | Edit Custom Properties menu and add something like this: idea.max.intellisense.filesize=4500 for 4.5 MB limit. The size is in Kilobytes.

Please use carefully, indexing large files may influence index update speed dramatically.

Solution 2

Ran into this recently with a project in 'bitbucket.org' GOPATH not finding ones in 'github.com'. Checked the "Index entire GOPATH" box and it fixed it.

This option is present at: Files > Settings (Preferences) > Go > GOPATH

Solution 3

Possibly not valid for the original context, but the workaround I discovered is to rename the file where the method or other identifier is defined, allow Goland to reindex, and then rename it back to the original name.

Solution 4

I had the same problem and this worked for me:

  1. From the main menu, select File | Invalidate Caches.

  2. In the Invalidate Caches dialogue, you can select additional actions that the IDE will perform while removing the cache files:

  3. Clear file system cache and Local History

  4. Click Invalidate and Restart.

Solution 5

For me, none of the above solutions worked. Finally I could solve it by enabling "Enable Go Modules Integration" checkbox located under Preferences > Go > Go Modules.

Share:
11,042
Sergey Andrianov
Author by

Sergey Andrianov

Updated on July 12, 2022

Comments

  • Sergey Andrianov
    Sergey Andrianov almost 2 years

    How to solve this problem? The program works. But the methods in Gogland are highlighted in red. Qt version 5.8 is added.

    Gogland (1.0 Preview) 1.0 EAP
    Build #GO-171.4694.61, built on June 27, 2017
    Gogland EAP User
    Expiration date: September 25, 2017
    JRE: 1.8.0_112-release-736-b21 amd64
    JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
    Linux 4.8.0-58-generic
    
    
    batis@dev:~$ printenv | grep GO
    GOROOT=/usr/lib/go-1.8/
    GOPATH=/home/batis/gocode/
    
    package main
    
    import (
        "os"
        "github.com/therecipe/qt/widgets"
    )
    
    func main() {
        widgets.NewQApplication(len(os.Args), os.Args)
    
        //create a window
        window := widgets.NewQMainWindow(nil, 0)
    
        ......
    
        widgets.QApplication_Exec()
    }
    

    Some image

    GOPATH

    Some image

    Test run OK!

  • Mark
    Mark about 4 years
    This sorted me out after updating to 2020.1.
  • Abiral
    Abiral about 4 years
    The option is present at : Files > Settings (Preferences) > Go > GOPATH
  • Stéphane Bruckert
    Stéphane Bruckert almost 4 years
    what if this happens for 100 files?
  • Eric Alford
    Eric Alford over 3 years
    This was the only thing that worked for me after trying the other avenues. Restarting didn't even work.
  • Fadyboy
    Fadyboy about 3 years
    This eventually worked for me though I had to restart Goland
  • Rafael Eyng
    Rafael Eyng almost 3 years
    I tried this, I renamed the file (first it asked me to confirm because the file was from outside the project), and it worked. Then I tried to rename it back to the original and the IDE wouldn't let me (wouldn't even show the confirmation prompt). But then the "undo" worked, even though it didn't show that it worked until I restarted. Very confusing, but thanks for the suggestion!
  • Shah Zain
    Shah Zain over 2 years
    This worked for me too!