-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
cmd/go: support @tip as an alias to "the latest development version" #42545
Comments
I'm not sure I understand the use-case. I would generally expect a user explicitly requesting an unreleased version to have some reason for using that unreleased version, in which case they probably also know what branch or commit they're trying to get — for example, they may have filed a bug, and the maintainer of the module may have replied with a request that the consumer try out the fix before it is tagged. But then the maintainer can also tell them which branch to request... Could you give some more detail on when this comes up? |
I agree that sometimes one is already familiar with upstream development, but I disagree that that's always/often the case. In fact, having to check the upstream's site/repository before I need to feels like busy work. For example, my most common use-case is when I think I've found a bug in a third party module, and I want to quickly re-run my tests with their latest development version before I file a bug. I shouldn't need to know what VCS they use to perform this Another similar use case is when I use a third party Go project, and I want to help test their development version before final releases. Historically, that would be a plain GOPATH-mode Also, I should emphasize the point about portability. Using
|
Like @mvdan, this is a common thing for me to want to do. "Have they fixed this bug on tip?" |
I'd support |
Those are interesting use-cases, but I see several very different queries there:
That sounds like “latest commit on the default branch” — but what leads you to believe that their latest development version is on the default branch at all? (They could be actively refactoring on a non-default branch, or fixing bugs on a release branch and backporting the fixes to development.) Or maybe “latest commit reachable from any branch”? But then the query would potentially hop back and forth between multiple very different branches. Or maybe “latest commit on the same branch as the latest tagged release”? But that would give you a stale commit for projects that use release branches. In other words: I think this use case fundamentally requires at least a cursory understanding of how the project organizes their development.
For projects that issue pre-releases, that sounds to me like “highest tagged version, even if it's a pre-release”, which is certainly an interesting use case but semantically very different from “latest commit on ”. In contrast, the assumption of “latest commit” would imply a Go-style freeze/thaw cycle or development continuing on a development branch, rather than (say) development continuing on the default branch and release stabilization occurring on a release branch. Again I think that fundamentally requires some understanding of the project. |
I think we could do the “highest tagged version, even if it's a pre-release” behavior within The only thing we could do in terms of “latest commit on the default branch” that generalizes to the existing proxy protocol would be “ |
I believe |
Yes, at least in git terms, I do mean latest commit on the default branch. I do generally expect a VCS repository to have the default branch be the latest development, at least as new as the last tag. If a project doesn't follow that pattern, I could always check their docs/site and use
If someone wants to propose I generally disagree that Go projects developing their latest code in a non-default branch will be a problem. If that were true, then it would have been a problem for the old GOPATH-mode |
For what it's worth, I'm happy to restrict the wording from "the latest development version" to "the latest commit of the default branch". I only went for the former because the latter felt very git-centric. |
#29761 :-) |
@hyangah thanks for the link, I hadn't seen that issue. It seems like the general resolution there was "we don't want to encourage this behavior" - I disagree with that point today, because plenty of how-tos and docs already tell people to use I wouldn't mind if this mode skipped module proxies, to be honest. Or support in the proxy protocol could be done at a later time if that would be easier. |
What would need to change in the proxy protocol to get "the latest commit of the default branch"? I would think that if the The TTL should be short, but probably no different than other branches. |
Hmm, that's a good point. We don't need to change the proxy protocol if we use |
@jayconrod Yes, it's the same as I don't think proxy.golang.org serving On the other hand, I think proxies can choose to just return 404/410 on |
Problem statement
Historically, one would use
go get -d github.com/foo/bar
and the repository would be checked out insideGOPATH
. What was nice about it is that the default branch would be used, usually meaningmaster
on git, for example.Now that we're in the world of modules, we can use
go get -d github.com/foo/bar@latest
to grab that module's latest released version, regardless of the VCS usptream is using.However, note that "the latest released version" is not quite the same. If one wants to use the latest available code ignoring releases, the general advice is to use
@master
. This is equivalent to using the version at the commit pointed to by the branchmaster
.While git is massively popular and
master
is also a very popular default branch name for it, this method has significant downsides. For example:master
branch/tag/refmaster
branch but have a different default branch, leading to confusing behaviormaster
withmain
(as willgit
, eventually!), it will be hard to remember what modules should be used with@master
versus@main
In other words, we have no way to say "the latest development version", usually meaning the latest commit from the default branch.
Proposed solution
Just like
@latest
is a special version, I think we should add another to have the meaning above: the latest development version.Naming this special version might be hard. I can see arguments in favor of a number of options:
@master
, since it already has this meaning for many people, and many users and scripts already use it. However, it goes against the effort to replacemaster
withmain
in git.@main
, as an alternative to@master
following git.@HEAD
, which means "default branch" in git. Very weird to have it be all-caps though, so maybe@head
instead.@tip
, borrowing from the hg/mercurial terminology@dev
,@devel
,@unstable
, or some other English word meaning "latest version ignoring stable releases"I personally am in favor of
@tip
because it's short to type, and because it's very unlikely to cause problems with existing branch/tag names in git, given how such a name would be very confusing to anyone familiar with hg. I'm not sure if it would cause any problems with people currently using@tip
with hg repositories.Related issues
cc @myitcv @rogpeppe @ianthehat @bcmills @jayconrod
The text was updated successfully, but these errors were encountered: