Golang gurus,
I'm currently trying to modularize my project with the help of Golang plugin, and I come across this dependency vendoring dilemma.
Let's say we have a project layout:
- Two different projects in separate repo: `Host` and `Guest`
- `Host` depends on package `pkgA`
- `Guest` depends on package `pkgA` too
- `Guest` is compiled as plugin, and loaded by `Host`
- `pkgA` is vendored into both `Host` and `Guest`
In this situation, `pkgA` would be loaded twice and independently, meaning there are two instance of the package in the program, one lives in `Guest` and one in `Host`. init() would be called twice as well
Particularly, I'm dealing with
golang.org/x/net/trace package, which actually registers an endpoint /debug/requests. The second attempt would panic because of double-registration.
I'd appreciate any advice on how to manage common dependencies of plugin and main project, thank you!
- J