go-lang-plugin-org / go-lang-idea-plugin

Google Go language IDE built using the IntelliJ Platform
https://plugins.jetbrains.com/plugin/5047
Other
4.56k stars 570 forks source link

Adding new packages into classpath of an existing GoSDK doesn't resolve. #461

Closed coocood closed 10 years ago

coocood commented 10 years ago

It is caused by index cache.

In other language change library would trigger index rebuilding(a progress bar progressing at the bottom of the windows), so the newly added library will be resolved.

Sometimes copy&paste code from other place to IDEA project also doesn't resolve,

So, I have to manually invalidate cache, and restart the project to get it work.

Is there any way to hook on to SDK modification, and rebuild index automatically?

dlsniper commented 10 years ago

As far as I can see there's no way to do it automatically. At least the copy & paste issue is strange. Do you have a better example? Afaik IDEA should manage refreshes automatically.

dlsniper commented 10 years ago

I've just took the code from here: http://godoc.org/github.com/lib/pq, pasted into the plugin, run the intention go get on the import to fetch the library and everything went as expected, I could click on the import statement, navigate in the package and so on. Same happens if I import "github.com/garyburd/redigo/redis" and tests it.

Thanks.

coocood commented 10 years ago

copy&paste works fine most of the time. I can't reproduce it either, never mind about it.

The issue is about adding folder in SDK classpath, if you have more than one GOPATH, you want to add a particular one to an SDK. then after you added it, the new packages in it can't be resolved, unless you invalidate the cache and restart.(I didn't know invalidating cache can solve the problem until recently).

Another question is do you have any idea about why packages added in library can not be resolved?

Thanks.

mtoader commented 10 years ago

My guess is that SDK are in a sense immutable. Once they are created it's hard to trigger refresh on them. And this makes sense because they are supposed to be big and it's not that practical to refresh them all the time. So adding new entries into the SDK should be a very low frequency operation.

Normally multiple entries in GOPATH should be handled as libraries since libraries are refreshed correctly as far as i know. There are plans to make the GOPATH manageable inside the IDE. That should also solve most of hte issues caused by people messing up with the GOPATH.

So the tl;dr version. If you add to the sdk make sure you add them very rarerly and invalidate the caches for now.