Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/go: add signal for `go get -u` to track branch? #26964
I already posted an issue regarding go.mod files.
This one is a little bit different but little bit linked to that old one.
I'm actually developping multiple repositories using 2 branches master and dev. Those branches are defined for each repositories. Lets assume I have the following ones:
I was wondering if there is a way to specify a branch for a specific repository inside the go.mod file.
The reason why I'm asking that is that, when I'm actually runing the
So I was thinking that maybe I can tag my dev branch and then specify the version I want to grab but it means that I will need to tag everytime I want to test my dev branch.
Does anyone have already face that pb?
Hope my explanations are clear :s
Thanks in advance ! :)
@maeglindeveloper: There might well be a better answer, but I think one approach would be to run
I have not tested your specific case before, but some related snippets from the documentation:
and (with emphasis added):
Those snippets are from a few different sections of the doc, but this section is perhaps most relevant:
Sorry if that is off base, but what do you think about trying that?
@maeglindeveloper and there is a little more background here:
I think part of the intent of modules is:
In addition, my understanding is the default behavior of a
Taking all of that together, maybe it is not crazy that
Note that go mod -sync does not update dependencies. We renamed it to go mod tidy, which hopefully will be less confusing in that respect. go get -u is what updates dependencies, or just 'go get dependency-name', which defaults to @latest.
The command you want for an explicit update right now is just
go get myrepo2@dev
I've been thinking for a while about whether to have a special comment in the go.mod that means "when you update, look for this branch", in which case you could use
The tricky part about a “use this branch” annotation is transitive dependencies.
So I think if we support this sort of branch redirect, it — like
referenced this issue
Oct 25, 2018
referenced this issue
Jan 23, 2019
This doesn't seem to work right if there is a
In our case we need to support the use of Gitlab subgroups, so we have to use a replace directive like:
At least it's generating the version string so I can copy that into the right place, but usability-wise it's a bit of a nightmare.