How to configure Intellij IDEA + Go language plugin to support the imported packages

3,293 views
Skip to first unread message

Павел Поляков

unread,
Jan 21, 2014, 7:15:08 AM1/21/14
to golan...@googlegroups.com
Hi,

I'm using IntelliJ IDEA and Go language plugin  ( http://plugins.jetbrains.com/plugin/5047?pr= ) for development.

But, when I'm importing the 3rd party package, like hood ( http://github.com/eaigner/hood ).

The I see the next:

Which means, that I don't have an autocomplete for those packages.

The $GOPATH is set correctly.

How can I overcome this?
Any suggestions?

Thanks,

Juan Alvarez

unread,
Jan 21, 2014, 6:36:46 PM1/21/14
to golan...@googlegroups.com
The plugin does not know about your GOPATH. One thing you can do to get around this is to create symlinks to mirror $GOPATH/src to $GOROOT/src/pkg.
If you are still not getting IntelliJ to know about your packages, File > Invalidate Caches / Restart. In fact, I have to do this frequently. It's a bit of a pain but it works.

Florin Patan

unread,
Jan 21, 2014, 6:39:15 PM1/21/14
to golan...@googlegroups.com
Hi,



And $GOPATH is 'never' correctly set as there's no 'correct' way to set it: I have multiple paths in it and I never create projects inside the first directory, others have only one directory and so on :)

Also, please include some more information about where 'go get' imported packages are and what is IDEA viewing about your projects.

As a final word, it might be more easy to report issues on github (unless they are not already reported, as it's easier for us to track issues in the plugin and fix them).



Regards,
Florin

Павел Поляков

unread,
Jan 22, 2014, 3:38:22 AM1/22/14
to golan...@googlegroups.com
The case is I'm not sure that is a bug. Because I don't know if plugin should catch up the installed packages.

Ok, so to be more precise:

My $GOPATH is /Users/PavelPolyakov/IdeaProjects/
The project is located here: /Users/PavelPolyakov/IdeaProjects/src/github.com/PavelPolyakov/martini-app-api

The file structure of the project is the next:

The packages, which were download by "go get" are located here (their sources):

And the *.a files are located here:


The $GOROOT/pkg looks the next way:

And the $GOROOT/src/pkg looks the next:


So, as I understand the plugin can autocomplete only those packages which are represented in the $GOROOT/src/pkg folder?
Is that the right assumption?

So I should link my downloaded sources to the $GOROOT/src/pkg.
Like /usr/local/go/src/pkg/github.com/eaigner/hood would be linked to /Users/PavelPolyakov/IdeaProjects/src/github.com/eaigner/hood ?

Or I miss something?

Thanks in advance,

p.s. I would create a bug report when I'm sure that this is a bug, not the wrong configuration by me.




среда, 22 января 2014 г., 1:39:15 UTC+2 пользователь Florin Patan написал:

Павел Поляков

unread,
Jan 22, 2014, 3:27:08 PM1/22/14
to golan...@googlegroups.com
This had helped me:

sudo ln -s /Users/pavelp/IdeaProjects/src/github.com/ ./github.com

Then File -> Invalidate Caches

среда, 22 января 2014 г., 10:38:22 UTC+2 пользователь Павел Поляков написал:

Florin Patan

unread,
Jan 22, 2014, 6:35:39 PM1/22/14
to golan...@googlegroups.com
That is wrong and should not be done as it's explicitly breaks what GO manual says about usage of GOROOT and GOPATH.

The plugin does support GOPATH, in most conditions but proper information should be given by the original poster in order to solve this.

Maybe we lack in documentation but then again, we are accepting patches for everything, including documentation for other users ;)


Thanks.

Florin Patan

unread,
Jan 22, 2014, 6:40:30 PM1/22/14
to golan...@googlegroups.com
That is wrong and should not be done.

Please revert it and post the information given by Tools -> Go Tools -> go plugin Debug internals -> go sdk data as it will contain the necessary information to help you solve the issue in a proper way.


Thanks.

Павел Поляков

unread,
Jan 23, 2014, 1:39:23 PM1/23/14
to golan...@googlegroups.com
Since I did the sync, it requires me to use "sudo" during the "go get":
go install github.com/go-sql-driver/mysql: mkdir /usr/local/go/pkg/darwin_386/github.com: permission denied
If I agree it installs the "*.a" files there.

Here are my internals:
Project dir -> /Users/PavelPolyakov/IdeaProjects/src/github.com/PavelPolyakov/martini-app-api
GO_GOROOT_PATH -> /usr/local/go
GO_BIN_PATH -> /usr/local/go/bin/go
GO_GOPATH_PATH -> 
TARGET_OS -> Darwin
TARGET_ARCH -> _386
VERSION_MAJOR -> go1.2 darwin/386
VERSION_MINOR -> 
Extended Go Env -> 
SHELL=/bin/bash
TMPDIR=/var/folders/kd/qnznkl9j4xgdxrx1djc10fn40000gn/T/
__CF_USER_TEXT_ENCODING=0x1F5:0:0
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Users/PavelPolyakov/IdeaProjects//bin:/Users/PavelPolyakov/IdeaProjects/src/github.com/PavelPolyakov/martini-app-api/bin
GOROOT=/usr/local/go
GOPATH=/Users/PavelPolyakov/IdeaProjects/:/Users/PavelPolyakov/IdeaProjects/src/github.com/PavelPolyakov/martini-app-api
USER=PavelPolyakov
HOME=/Users/PavelPolyakov
LOGNAME=PavelPolyakov
Apple_PubSub_Socket_Render=/tmp/launch-AErVoW/Render
__CHECKFIX1436934=1
SSH_AUTH_SOCK=/tmp/launch-VVPQ5n/Listeners

Seems that the $GOPATH is correct

четверг, 23 января 2014 г., 1:40:30 UTC+2 пользователь Florin Patan написал:

Florin Patan

unread,
Jan 23, 2014, 2:42:56 PM1/23/14
to golan...@googlegroups.com
Hi,


From what I can see, GO_GOPATH_PATH is empty which means that for some reason, when the plugin was created, the PATH could not be properly loaded from the system.
If you are using IDEA, can you please delete the Go SDK and create a new one?
If that doesn't work then submit an issue on GitHub and I'll try to help you out maybe with a custom build to better understand the problem / fix it.
Thanks!



Regards,
Florin

Павел Поляков

unread,
Jan 23, 2014, 2:57:10 PM1/23/14
to golan...@googlegroups.com
Thanks man, that helped!

I've removed the SDK, then add one.
Then I've also created the new project (over the old one).

четверг, 23 января 2014 г., 21:42:56 UTC+2 пользователь Florin Patan написал:

Florin Patan

unread,
Jan 23, 2014, 3:09:13 PM1/23/14
to golan...@googlegroups.com
I'm glad it worked!

We are working on improving the experience but any help is very much appreciated.


Kind regards

Juan Alvarez

unread,
Jan 23, 2014, 8:58:57 PM1/23/14
to golan...@googlegroups.com
I can't believe how messed up my setup was. Thank you Florin. 
Reply all
Reply to author
Forward
0 new messages