英文:
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仍然在一些代码上报错。
正如你在图片中所看到的,我有execlise包,但它仍然报错。不仅如此,我还有其他文件上的错误。
英文:
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
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
答案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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论