'Valid methods in being highlighted in red 'Unresolved Reference'
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()
}
Solution 1:[1]
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 2:[2]
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 3:[3]
I had the same problem and this worked for me:
From the main menu, select File | Invalidate Caches.
In the Invalidate Caches dialogue, you can select additional actions that the IDE will perform while removing the cache files:
Clear file system cache and Local History
Click Invalidate and Restart.
Solution 4:[4]
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.
Solution 5:[5]
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
Solution 6:[6]
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.
Solution 7:[7]
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
Solution 8:[8]
You need to "Enable Go Modules Integration" by going into "File" and selecting settings and then "Go Modules"
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 | StealthVice7 |
| Solution 2 | Schparky |
| Solution 3 | Milad Saeedi |
| Solution 4 | emreoktem |
| Solution 5 | Stéphane Bruckert |
| Solution 6 | Dmitry Rog |
| Solution 7 | Siraf |
| Solution 8 | Shah Zain |





