Skip to content

cmd/go: support @tip as an alias to "the latest development version" #42545

@mvdan

Description

@mvdan

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 with main (as will git, 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:

  1. @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 replace master with main in git.
  2. @main, as an alternative to @master following git.
  3. @HEAD, which means "default branch" in git. Very weird to have it be all-caps though, so maybe @head instead.
  4. @tip, borrowing from the hg/mercurial terminology
  5. @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

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureRequestIssues asking for a new feature that does not need a proposal.GoCommandcmd/goNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.modules

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions