-
Notifications
You must be signed in to change notification settings - Fork 9.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't vendor dependencies for etcd/client #4913
Comments
@schmichael The short answer is we are considering moving client/clientv3 to its own top level pkg. |
It is not only client packages. I am having the same problem when trying to implement various etcdserverpb.XServer interfaces. See this mailing list post on golang-nuts and this repo which demonstrates the problem. This problem was raised earlier on golang-dev, see this post and Russ's reply immediately after, where it is stated
So, @schmichael's request generalizes to: don't have vendoring for any code which may be imported by other packages. This basically means anything other than |
I think the rule is
coreos/etcd satisfies all of the conditions. Therefore, one option could be splitting etcd into two repos:
Another option would be removing all exported types from the vendor folder, starting with golang.org/x/net/context. |
@schmichael For the record your option 1 is definitely not a viable solution due to reasons outlined above. |
@peterbourgon Thanks for the extensive analysis. We are looking into this problem and will try all the possible options. We want everything inside one repo if possible and also want to ensure go tool works (like go get, go install). We will get back to you soon. |
@xiang90 There is extensive discussion on the mailing list and the Gopher slack #vendor channel, I recommend coming to the latter to get a proper framing/context for the discussion. If you need one repo, then I think you will need to build your binaries with nonstandard tooling (e.g. glide, gb, etc.) and check in a vendor manifest file but not the vendor/ directory itself. |
Thanks! My library now builds without vendoring! The solution seems a bit awkward (symlinking root into cmd/vendor), so I hope the discussion around vendoring best practices continues in the larger Go community. Edit: Turns out my hopes already came true: https://groups.google.com/forum/m/#!topic/golang-dev/4FfTBfN2YaI |
@schmichael We are following that discussion. So the current solution might not be the final solution. We just try to make it work at least. |
I have run into the same problem @reterVision did in #4904 when attempting to implement a fake etcd interface in a library.
I'm new to vendoring in Go, but my understanding is that using vendoring in libraries (that is: non-main non-internal non-test packages with public APIs) is discouraged* and that vendoring should be left up to the binaries (executables).
I'm unable to find direct guidance on the subject in the official vendoring doc, but the passage seems to indicate it's an open issue?
Example
To give a concrete example of this issue:
context.Context
arguments resolve toetcd/vendor/.../context
while my fake implementation'scontext.Context
arguments resolve to the global context package.(If
context.Context
were a struct instead of an interface my non-test code would have already run into the vendoring issue.)As far as I can tell I have 4 options to resolve this build error:
etcd/pkg/{pathutil,types}
and rewrite imports (just to ensure vendoring is totally avoided).If 1 - vendor everywhere - is the solution I'd just love some other examples in the Go community of libraries vendoring, or feedback from core developers that this is the correct path for all Go projects to take.
* My only source for this is some reputable members of #go-nuts who didn't give consent for me to name their names here. :)
The text was updated successfully, but these errors were encountered: