-
Notifications
You must be signed in to change notification settings - Fork 150
[RFC] Adding support for creating gb projects that don't contain main packages #49
Comments
For this reason, libraries in cargo don't specify which version they go with, in gb's case that would be analogous to not allowing (or at least discouraging) vendoring when the project is meant as a library. |
@andrewchambers i don't think there is anything needed here. Go code already indicates the names of the packages it builds upon, there is no formal way for a Go package to say it needs a specific revision (nee version) of a dependency, so there is no need for us to discourage the use of something that doesn't exist. |
Its just annoying if the library has one vendors commit in its manifest and you have another in yours. Gb can just use precedence or something, I don't mind. I am pretty happy with Gb being program only. |
From experience in other languages, secondary dependencies of explicit dependencies in a project are included as is unless the same dependency is already present. Many of the existing dependency/manifest files allow for specifying a range of versions (revisions) that are valid for the library to behave correctly. This of course conflicts with the current notion of vendoring since a specific snapshot of the dependency is versioned with the source code (as well as the code at a particular version being available). There may need to be a trade-off defined for libraries that allow a range of versions to pull those dependencies in dynamically. The basic logic would be:
The bottom line is that libraries are generally not as strict with dependency versions as projects, so that needs to be considered when vendoring a library in the |
Thank you for your comment. I want to point out that I believe that Go Because of this, it is not possible to specify version ranges as no such This is of course not to say that such things should exist, as they are On Wed, Jun 10, 2015 at 12:21 PM, Byron Ruth notifications@github.com
|
So then it may be that, in June 2015, gb should either pave the way for standardizing the notion of a version or simply does not support libraries. I support the former since gb already has momentum with "deviating from the norm" (go get).
|
gb projects can be libraries, which I interpret as projects which don't have command (package mains) packages, that exists today. What is missing, not just from gb, but the whole Go ecosystem is a widely accepted notion of releasing a project (or package, or set of packages). That is, taking a specific copy of some Go source code, possibly identified by a revision hash or marker in a VCS system, and giving that a human (and possibly machine) readable version identifier. This is not something gb seeks to do, gb is only concerned with building source it finds on disk in the prescribed project format. With that said, this is absolutely something that needs to be done, but that is a different discussion, for a different issue tracker. |
I understand that and agree gb should focus on what it has be designed to do (and as you made very clear when describing the gb-vendor tool). By paving the way I simply mean that the gb community appears to be in a good position to define:
Based on the constraints you've declared for the tool, I am not sure there is anything that could or should be done for using gb in a library context. |
Can you please clarify what you mean by library for me. Gophers can use gb today to develop gb projects which are libraries, ie, they are projects that contain no main package and there is an expectation that their source will be vendored into another project. As for versioning Go packages, this is not something that gb is focused on, but it is not to say that I am not working on it. |
Sorry:
I simply mean that what has been described in this issue sounds to all be centered around dealing with versions. As you stated this is not something that the gb tool should directly deal with, but rather a plugin. |
ok. Thanks for confirming. To be clear, the lack of a version identifier for Go packages is a very big On Wed, Jun 10, 2015 at 8:27 PM, Byron Ruth notifications@github.com
|
@davecheney what forums would those be? Can I haz link(s)? |
https://groups.google.com/forum/?hl=en-GB#!forum/go-package-management And it mainly consists of me pointing out that go packages don't have On Fri, Jun 12, 2015 at 12:42 AM, Manuel Mendez notifications@github.com
|
ok, I've seen those just thought there may have been something more substantial or something I may have missed. Thanks |
nope. i can only boil one ocean at a time. On Fri, Jun 12, 2015 at 1:28 AM, Manuel Mendez notifications@github.com
|
Welp, seems like its working. Keep making soup sir. |
Arguably relevant to the discussion (posted on HN): https://groups.google.com/forum/#!msg/golang-dev/74zjMON9glU/4lWCRDCRZg0J |
Sorry if I’m missing something, but how do I include a gb library dependency via |
@aviflax this isn't supported by gb vendor yet. It's on the roadmap. For the moment you'll have to vendor manually by copying the relevant parts from one gb project to another. |
Got it, thanks!
|
Hi @davecheney I just try gb for some day and far from understand what |
@nvcnvn gb does not use the vendor mechanism that is used by go get. |
I know this is old and maybe not the right place for it, but I have a question on what is the recommended best way to deal with libraries that vendor themselves. My question is, how do you recommend to handle this sort of painful situation right now with gb? Is it possible that if |
This is a blanket issue to cover questions on the go-pm mailing list and other issues.
Supporting gb projects that don't have a main package
Currently a
gb
project is defined as a collection of packages and main packages (commands), along with supporting source code invendor/src/
.At the GDG presentation in Berlin in April I said that
gb
was not suitable for libraries (projects consisting of non main packages, to use an imprecise definition), after reflecting on this for a few days I think this restriction may have been premature and probably motivated by trying to simplify the story for the GDG audience.Specifically there is nothing preventing a library author using
gb
, and in fact many of the reasons why a library author would want to take advantage of the reproducibility guarantees that agb
project attempts to offer.Distinguishing between projects and library projects
In principal a
gb
project, and agb
library project (need to find a better description) are the same, they both contain some code in$PROJECT/src/
, they both may contain some supporting dependencies invendor/src/
. The only remaining point of differentiation isgb build
executed in the former may produce some output in$PROJECT/bin/
, while the latter most likely will not.In short, this prohibition was short sighted and unnecessary.
However, with this prohibition relaxed, a new question arises: how can one
gb
project consume anothergb
project as a dependency ? It turns out that this isn't a very difficult proposition, but it is regrettably manual at the moment. Consider this scenario,mongodb/
is the project root of some library,twitter
is the project root of agb
project that consumesmongodb
's packages as a dependency. The names are completely arbitrary.mongodb
andtwitter
are developed separately, they live in different respositories. Themongodb
client has a dependency onbson
, and includes its source in its'vendor/src/
directory.mongodb
also has a dependency ongocheck
for tests.The process for vendoring
mongodb
intotwitter/vendor/src/
would be to copy the contents ofmongodb/src/*
intotwitter/vendor/src/
and also selectively copyingmongodb/vendor/src/*
intotwitter/vendor/src/
. The project owner oftwitter
may choose to omit thegocheck
dependency ofmongodb
, of they may choose to include it for completeness.Open issues
The process described above is not difficult, but it does require the package owner to be cognoscente of their actions when importing new dependencies into their project. Automating this initial import with tools is difficult at the moment due to a lack of version information in Go code in general (see #20 for a distinction between version and revision). Automating the orderly upgrade of a set of vendored dependencies is more difficult again.
Tackling these issues are outside the scope of this specific bug, and arguably outside the code mandate of
gb
-- it just provides the mechanism to work with a "project" of Go code, it is mute on how that source is assembled -- but feels like ample fuel for a plugin that tackles these complicated issues.The text was updated successfully, but these errors were encountered: