在红色的“未解决的引用”中突出显示的有效方法

huangapple go评论75阅读模式
英文:

Valid methods in being highlighted in red 'Unresolved Reference'

问题

如何解决这个问题?程序是可以工作的。但是Gogland中的方法被标记为红色。已添加Qt版本5.8。

Gogland(1.0 Preview)1.0 EAP
构建号:GO-171.4694.61,构建于2017年6月27日
Gogland EAP用户
到期日期:2017年9月25日
JRE:1.8.0_112-release-736-b21 amd64
JVM:由JetBrains s.r.o提供的OpenJDK 64位服务器VM
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)

//创建一个窗口
window := widgets.NewQMainWindow(nil, 0)

......

widgets.QApplication_Exec()

}

在红色的“未解决的引用”中突出显示的有效方法

在红色的“未解决的引用”中突出显示的有效方法

在红色的“未解决的引用”中突出显示的有效方法

在红色的“未解决的引用”中突出显示的有效方法

英文:

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()
}

在红色的“未解决的引用”中突出显示的有效方法

在红色的“未解决的引用”中突出显示的有效方法

在红色的“未解决的引用”中突出显示的有效方法

在红色的“未解决的引用”中突出显示的有效方法

答案1

得分: 36

最近在 'bitbucket.org' 的项目中遇到了这个问题,GOPATH 找不到 'github.com' 中的项目。勾选了 "Index entire GOPATH" 选项后问题得到解决。

该选项位于:文件 > 设置(首选项)> Go > GOPATH

英文:

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

答案2

得分: 14

这些方法是在一个大的生成文件中定义的,该文件未被Gogland索引。要更改限制,您应该更改idea.max.intellisense.filesize

要做到这一点,通过Help | Edit Custom Properties菜单打开自定义属性文件,并添加类似于idea.max.intellisense.filesize=4500的内容,以设置4.5 MB的限制。大小以千字节为单位。

请谨慎使用,索引大文件可能会极大地影响索引更新速度。

英文:

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.

答案3

得分: 3

可能对于原始上下文来说并不适用,但我发现的解决方法是将定义该方法或其他标识符的文件重命名,让Goland重新索引,然后再将其改回原始名称。

英文:

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.

答案4

得分: 2

对我来说,上述的解决方案都没有起作用。最后,我通过在“首选项”>“Go”>“Go模块”下启用“启用Go模块集成”复选框来解决了这个问题。

英文:

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.

答案5

得分: 1

我遇到了同样的问题,以下方法对我有效:

  1. 从主菜单中选择 文件 | 无效缓存。

  2. 在无效缓存对话框中,你可以选择在删除缓存文件时执行的其他操作:

  3. 清除文件系统缓存和本地历史记录。

  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.

答案6

得分: 0

这也可能发生在将go.mod从另一个项目复制过来而没有更新项目名称的情况下:

// go.mod

module github.com/org/new-project

go 1.15
英文:

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

答案7

得分: 0

对我来说,问题出在我将GOPATH设置为1.15,但GOROOT设置为1.14,所以你需要将它们设置为相同的版本。你可以在首选项 -> Go -> GOROOT或GOPATH中找到这些设置。

我使用gvm - Go版本管理器,这就是为什么我在系统中有多个Go版本。

英文:

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.

答案8

得分: 0

我在Windows 10上使用Goland 2021.1和Go SDK 1.13时遇到了同样的问题。我通过安装最新的Go版本1.16.3解决了这个问题,同时保留了我项目所需的1.13版本。原来,我的Windows 10操作系统已经安装了与GoLand 2021.1和SDK 1.13不兼容的安全更新补丁。

英文:

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

答案9

得分: 0

你需要通过进入"文件",选择"设置",然后选择"Go模块"来"启用Go模块集成"。

在红色的“未解决的引用”中突出显示的有效方法

英文:

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

在红色的“未解决的引用”中突出显示的有效方法

huangapple
  • 本文由 发表于 2017年7月5日 17:03:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/44921623.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定