-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Description
Problem statement
Historically, one would use go get -d github.com/foo/bar
and the repository would be checked out inside GOPATH
. What was nice about it is that the default branch would be used, usually meaning master
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 branch master
.
While git is massively popular and master
is also a very popular default branch name for it, this method has significant downsides. For example:
- It likely won't work with other VCS systems, since they often don't have a
master
branch/tag/ref - A git repository could easily have a
master
branch but have a different default branch, leading to confusing behavior - Since many git repositories are replacing
master
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
- x/pkgsite: support viewing a package @master #36811 - pkgsite's support for "the latest development version" would likely improve with this change, from the user's perspective and for VCS portability