英文:
Can Jetbrains GoLand use both GoModule and GOPATH?
问题
我正在进行fibrechannel项目的工作,而且还有一个与fibrechannel有依赖关系的同级项目(common项目)。
当我选择如下的启用Go模块集成
时:
IDE告诉我找不到logger。(请注意,我使用红色矩形标记了引用位置,实际上它位于common文件夹下)
当我取消选中启用Go模块集成
复选框时。(请注意,GOPATH的样子如下)
IDE告诉我找不到"github.com/pkg/errors"。
fibrechannel下的go.mod文件如下所示:
module fibrechannel/src
go 1.12
require (
github.com/pkg/errors v0.8.1
github.com/stretchr/testify v1.3.0
gopkg.in/iconv.v1 v1.1.1
gopkg.in/yaml.v2 v2.2.2
)
我是GO语言的新手,我只是希望IDE能够成功解析依赖关系。
我想知道在Jetbrains GoLand中是否有一种方法可以同时使用GOPATH和Go模块。如果没有,是否有一种方法可以修改go.mod文件以包含GOPATH?
英文:
I'm working in fibrechannel project, and there are same level project(common) that fibrechannel depends on.
When I select Enable Go modules integration
as below:
IDE tells me logger not found. (Note I'm using red rectangle to mark the reference and it's actually location under common folder)
After I unclick the Enable Go modules integration
checkbox. (Note GOPATH looks like below)
IDE tells me "github.com/pkg/errors" not found.
the go.mod under fibrechannel looks like below:
module fibrechannel/src
go 1.12
require (
github.com/pkg/errors v0.8.1
github.com/stretchr/testify v1.3.0
gopkg.in/iconv.v1 v1.1.1
gopkg.in/yaml.v2 v2.2.2
)
I'm a newbie in GO language, and I just want the IDE to resolve dependencies successfully.
I'm wondering if there's a way to make both GOPATH and GoModules work in Jetbrains GoLand. If not, is there a way to modify go.mod so that it can include GOPATH?
答案1
得分: 2
最后,我成功解决了这个问题。
顺便说一下,由于这是一个由许多团队成员维护的旧项目,我不想改变它的代码结构,我只需要在GoLand中读取内容而不引用任何未知的引用。
解决方案是不使用go模块。
我取消了“启用Go模块集成”,这样只有在venders
文件夹中找不到库。
然后我手动将venders
文件夹添加到GOPATH中。
现在所有的依赖都已解决!
英文:
Finally, I managed to solve this issue.
B.T.W, since this is an old project maintained by many team members. I don't want to change its code structure, all I need is to read the content without any unknown reference in GoLand.
The solution is NOT to use go modules.
I unchecked the Enable Go modules integration
so that only libraries in venders
folder not found.
Then I manually added venders
folder into GOPATH.
Now dependencies are all resolved!
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论