Editing both main code and dependency at the same time
Hi All,
I'm using the Go plugin for IntelliJ (which I think is the same thing as GoLand, but not 100% sure).
When working on the main code base, and a dependency at the same time, I could, in the past, simply delete the dependency from the vendor folder and the compiler / code checker / magic thing would find the copy of the code base in my src dir (all paths, etc. are intact). As my system has become more complex and now consists of dependencies with dependencies, the only real way I can make this happen is to remove ALL vendor folders from all dependencies in the chain - giving the IDE no choice but to look in the src directory.
Does anyone have some insight on how the "search" chain is functioning and perhaps suggest a way to edit these external libraries without having to cycle through the repo (dep ensure)?
Thanks a bunch for any help you can muster!
David.
请先登录再写评论。
Hi David,
> I'm using the Go plugin for IntelliJ (which I think is the same thing as GoLand, but not 100% sure).
It is 100% the same.
> When working on the main code base, and a dependency at the same time, I could, in the past, simply delete the dependency from the vendor folder and the compiler / code checker / magic thing would find the copy of the code base in my src dir (all paths, etc. are intact). As my system has become more complex and now consists of dependencies with dependencies, the only real way I can make this happen is to remove ALL vendor folders from all dependencies in the chain - giving the IDE no choice but to look in the src directory.
>
> Does anyone have some insight on how the "search" chain is functioning and perhaps suggest a way to edit these external libraries without having to cycle through the repo (dep ensure)?
Unfortunately, when using vendoring there is no other way to make this happen. The IDE/Go support plugin behave like the "go" tool does in this regard.
What might help you is migrating to Go 1.10+ (I'd recommend 1.11+) and using Go Modules to work on this kind of projects as Go Modules allows working with a "main" repository at the same time as a "dependency" by using a special directive called "replace". In this case, the IDE will also resolve to that "replace" directive and you can use the "Attach" feature when you open a second project from the IDE to keep both the "main" and the "dependency" project(s) opened under a single IDE window.
Hope this helps.