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

"Use GOPATH..." setting should be project-specific #1811

Open mmindenhall opened 9 years ago

mmindenhall commented 9 years ago

Currently within Preferences -> Languages & Frameworks -> Go -> Go Libraries, the "Use GOPATH that's defined in system environment" setting is applied to all of my Go projects. This is a setting that needs to be project specific rather than global, as projects vendoring their dependencies (e.g., with wgo or gb) won't use the system GOPATH. For example:

Project with vendored dependencies:

Project without vendored dependencies:

OS: Mac OS X 10.10.5 JDK version: Apple JDK 1.6.0_65 IDEA version: IU-141.2311.1 Plugin version: 0.9.460

dlsniper commented 9 years ago

I understand the point of view but there are a few things to consider:

My guess would be that we when creating a new project we should display the dialog for Go libraries and ask the user if the settings are ok or they should be changed. A checkbox with a remember settings should prevent this dialog to open every time if the user says so (the current notification should be displayed instead).

@zolotov, what do you think?

mmindenhall commented 9 years ago

All good points. My reason for filing this is precisely what you say in your 3rd bullet -- I'm working on a work project that uses wgo for vendoring, but I also have several other projects that are libraries that I've been playing around with or created as separate Intellij projects just to make it easier to navigate the source when I want to know how something I'm calling is implemented.

How about starting with "Use GOPATH..." set as the default when a new project is created, but persisting the setting per project instead of globally. That would seem to work for all use cases, and the issue of detecting tools can be solved separately.

dlsniper commented 9 years ago

Yes, having it by default enabled and stored per project makes sense (isn't it like this now? Sorry, I don't really use that feature).

mmindenhall commented 9 years ago

No, it's global. If I uncheck the box on one project, it's unchecked when I look at the settings from any other project. If I check the box, it's checked across all other projects.

zolotov commented 9 years ago

It's global because it controls global (application wide) libraries. Changing this logic will lead to the same confusion for some other users, it's six of one and half a dozen of the other. Also it's not easy to do because we should save settings compatibility with previous plugin versions and if at some point we'll decide to rollback it, it would be real pain.

And that's the idea. It's supposed that if you're going to rely on GOPATH env variables then you should rely on it until the end. If env variable doesn't suite for you (and I think you're right, single system-wide GOPATH was a lame idea) then you can use project-level libraries and IDE will construct GOPATH from it for each golang tool instantiation.

As for dependency management tools like gc, godep etc., I believe that plugin should be able to detect the fact that one of them is used and construct GOPATH without user's help but using conventions of that tools. So in case using dependency managment tool you won't see Go Libraries page at all. And this solution looks more properly to me instead of moving settings back and forth.

mmindenhall commented 9 years ago

Makes sense. AFAIK, the authors of gb and wgo are planning to be compatible with the go1.5 vendoring approach. So it would make sense that when a <project_root>/vendor folder is detected, the GOPATH is built from just the project sources and whatever's in that folder.

zolotov commented 9 years ago

gb and wgo are planning to be compatible with the go1.5 vendoring approach

Sounds great. I'll try to investigate this.

dlsniper commented 8 years ago

@zolotov I think this one could be labeled as up for grabs? If it doesn't require too much work, I'll try to look into it soon-ish as I can see the value in it (and I might need it as well). Thank you.

zolotov commented 8 years ago

I think this one could be labeled as up for grabs?

@dlsniper not really, I want to reimplement whole sdk/libraries settings and this issue is a part of it.

nickithewatt commented 8 years ago

+1 for this feature, I am trying to use gb and this is problematic for me at present

mqliang commented 8 years ago

+1 for the feature, so that I could modify gopath in IDE, rather than modify the system environment setting and restart IDE everytimes

zolotov commented 8 years ago

@mqliang disable using env $GOPATH and modify gopath in IDE, what's the problem?

orian commented 8 years ago

@zolotov For most simple scripts I don't mind the $GOPATH, but for some projects I use vendor dir and don't want the IDEA to search in $GOPATH for packages. Right now, every time I start IDEA I have to remove $GOPATH from project by hand.

zolotov commented 8 years ago

@orian and how making Use env GOPATH project-specific setting could help you?

orian commented 8 years ago

@zolotov I could uncheck it? And then remove the $GOPATH from project settings only once. Right now it's added automatically on every IDEA start.

zolotov commented 8 years ago

@orian why can't you uncheck it right now for all projects?