Goland在Windows上无法识别导入并抛出错误。

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

goland on windows not recognizing imports and throw error

问题

我已经按照这个文档启用了Go模块集成。
https://www.jetbrains.com/help/go/create-a-project-with-go-modules-integration.html#enable-go-modules-in-a-project
但是,正如你在下面的图片中所看到的,Goland仍然在一些代码上报错。
Goland在Windows上无法识别导入并抛出错误。

正如你在图片中所看到的,我有execlise包,但它仍然报错。不仅如此,我还有其他文件上的错误。
Goland在Windows上无法识别导入并抛出错误。

英文:

i have enabled the go modules integration according to this docs .
https://www.jetbrains.com/help/go/create-a-project-with-go-modules-integration.html#enable-go-modules-in-a-project
but yet again as you can see in image below . goland keep throwing error on some code i have
Goland在Windows上无法识别导入并抛出错误。

as you can see in image i have that execlise package but it keep giving error . not only that i have some error on other files
Goland在Windows上无法识别导入并抛出错误。

答案1

得分: 1

有时候在使用集成开发环境(IDE)时会出现这种情况,根据我的经验,可能有以下三个原因:

第一: go.sum 文件中的包版本差异。你应该清空 go.sum 文件,并运行 go mod tidy 命令。

第二: 你使用的版本可能比你期望的版本要旧或者新,所以该包可能不支持这些方法或者没有包含它们。你应该设置包的确切版本。(我建议你在这种情况下阅读包的文档)

第三: 你的 IDE 可能存在一些缓存问题。为了解决这个问题,你可以点击 "文件 -> 无效缓存" 来重新构建你的 IDE 缓存。

英文:

That happens sometimes with IDEs, from my experience it may happen because of at least three reasons.

first: the differences between package versions in your go.sum, you should empty the go.sum and run go mod tidy command.

Second: the version you’re using is older or newer than what you’re expecting, so the package does not support these methods or didn’t include them. so you should set the exact version of the package. (I suggest you read the documentation of the package in this case)

Third: your IDE has got some problems with the caches. for solving this: you should click on file -> invalidate caches to rebuild your IDE caches.

huangapple
  • 本文由 发表于 2023年2月1日 18:41:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/75308983.html
匿名

发表评论

匿名网友

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

确定