Valid methods in being highlighted in red 'Unresolved Reference'
Asked Answered
G

9

14

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!

Gamete answered 5/7, 2017 at 9:3 Comment(4)
What does it have to do with C++?Touchwood
The GOPATH seems to be incorrectly configured as well as the project seems to be in the wrong place. The project GOPATH should be removed and the project should be created under /home/batis/gocode/src/your/project/path. Then, make sure you have the dependency under /home/batis/gocode/src/github.com/therecipe/qtValenti
@Valenti Moved the project to /home/batis/gocode/src/batis/Qt. Problem still exists. Tell me please how you can check the dependencies.Gamete
project GOPATH deleted.Gamete
D
14

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.

Dacha answered 5/7, 2017 at 11:34 Comment(0)
S
37

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

Spooner answered 4/12, 2018 at 4:8 Comment(3)
This sorted me out after updating to 2020.1.Upgrowth
The option is present at : Files > Settings (Preferences) > Go > GOPATHOfris
This eventually worked for me though I had to restart GolandCarey
D
14

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.

Dacha answered 5/7, 2017 at 11:34 Comment(0)
C
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.

Celiaceliac answered 2/12, 2019 at 15:35 Comment(3)
what if this happens for 100 files?Celebes
This was the only thing that worked for me after trying the other avenues. Restarting didn't even work.Steapsin
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!Squarrose
W
2

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.

Worsted answered 25/1, 2022 at 16:36 Comment(0)
A
1

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.

Arnaldo answered 7/5, 2021 at 21:17 Comment(0)
H
0

This can also happen if go.mod is copied from another project without updating the project name:

// go.mod

module github.com/org/new-project

go 1.15
Haema answered 16/9, 2020 at 8:50 Comment(0)
B
0

For me, it was that I had GOPATH set to 1.15 but GOROOT set to 1.14, so you need to set them to the same version. You can find these settings in Preferences -> Go -> GOROOT or GOPATH.

I use gvm - Go Version Manager, that's why I have multiple Go versions in my system.

Banshee answered 28/2, 2021 at 9:49 Comment(0)
L
0

I had the same issue with Goland 2021.1 on Windows 10 with go SDK 1.13. I solved the problem by installing the latest go version 1.16.3 side by side to version 1.13 that I need for my projects. It turned out that my Windows 10 OS was patched with security updates that are not compliant with GoLand 2021.1 and SDK 1.13

Limeade answered 21/4, 2021 at 11:25 Comment(0)
P
0

You need to "Enable Go Modules Integration" by going into "File" and selecting settings and then "Go Modules"

enter image description here

Parkin answered 17/2, 2022 at 10:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.