简体   繁体   English

在IntelliJ中转到项目无法解决依赖关系

[英]Go Project in IntelliJ Not Resolving Dependencies

I have IntelliJ CE and I just imported a Go project that I cloned from GitHub. 我有IntelliJ CE,刚刚导入了从GitHub克隆的Go项目。 On my Mac, I have some folder organization where I group projects that I work on based on the technologies. 在Mac上,我有一些文件夹组织,可以根据这些技术对要处理的项目进行分组。 For example., in my Projects folder on my Mac, I have the following sub folders: 例如,在Mac上的“项目”文件夹中,我有以下子文件夹:

- go-projects
- scala-projects
- rust-projects
- ruby-projects

So I obviously checked out the Go project in the go-projects folder which looks like this: 因此,我显然在go-projects文件夹中签出了Go项目,如下所示:

Joes-MacBook-Pro:go-projects joe$ ll
total 0
drwxr-xr-x   3 joe  staff   102B Oct 28 07:51 bin/
drwxr-xr-x  19 joe  staff   646B Oct 24 06:48 golang-restful-starter-kit/
drwxr-xr-x   3 joe  staff   102B Oct 28 07:51 pkg/
drwxr-xr-x   3 joe  staff   102B Oct 27 10:23 src/

And if I get into the src folder, it looks like this: 如果我进入src文件夹,它看起来像这样:

Joes-MacBook-Pro:go-projects joe$ cd src
total 0
drwxr-xr-x  6 joe  staff   204B Nov  7 19:14 github.com/
Joes-MacBook-Pro:src joe$ cd github.com/
total 0
drwxr-xr-x   3 joe  staff   102B Oct 28 08:20 btcsuite/
drwxr-xr-x  16 joe  staff   544B Nov  7 19:16 eth-client/
drwxr-xr-x   3 joe  staff   102B Oct 27 10:24 ethereum/
drwxr-xr-x   3 joe  staff   102B Oct 28 07:51 tools/
Joes-MacBook-Pro:github.com joe$

Here is my Go related environment settings: 这是我与Go相关的环境设置:

# For Go projects, we set the GOPATH
export GOROOT="/usr/local/go"
export GOPATH="/Users/joe/Projects/Private/go-projects"
export GODEPS="/Users/joe/Projects/Private/go-projects/bin/godep"

Now I import one of the Go project into IntelliJ and I get to see the following error saying that it is not able to resolve a directory as it can be seen in the screenshot below! 现在,我将Go项目之一导入IntelliJ中,我看到以下错误,因为它无法解析目录,因为它可以在下面的屏幕截图中看到!

在此处输入图片说明

How can I get rid of this error? 如何摆脱这个错误? Any ideas? 有任何想法吗?

I just realized that when I clone the project, I should not do a git clone but rather do: 我只是意识到,当我克隆项目时,我不应该执行git clone而是要做:

go get -u github.com/golang/lint/golint

Not sure why this is so, but after doing this my IntelliJ was able to resolve every file on my project! 不知道为什么会这样,但是这样做之后,我的IntelliJ就能解析项目中的每个文件!

For golang projects, it's good to have Goland installed ( also a product of JetBrains ) Goland Download . 对于golang项目,最好安装Goland(也是JetBrains的产品) Goland Download Moreover for the above concern you can use: 此外,对于上述问题,您可以使用:

go get *the_project_to_clone*

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM