Skip to content

proposal: go/cmd: install should assume @latest in most cases #58285

Closed as not planned
@ConradIrwin

Description

@ConradIrwin

As a go programmer I create command line tools that I want to download and use on various machines. I'd like it to be as easy as possible to install those tools when I need them.

Until go1.18 it was possible to run go get github.com/superhuman/url64. This feature was moved to go install, and as part of that the syntax was changed to require @latest on the end, otherwise you (usually) get one of two possible error messages:

# in a module
$ go install github.com/superhuman/url64
no required module provides package github.com/superhuman/url64; to add it:
	go get github.com/superhuman/url64

# not in a module
$ go install github.com/superhuman/url64
go: 'go install' requires a version when current directory is not in a module
	Try 'go install github.com/superhuman/url64@latest' to install the latest version

I propose that:

  • In a module that has a specific version of github.com/superhuman/url64 in its go.mod: go install github.com/superhuman/url64 would act as it does today.
  • Otherwise (outside of a module, or in a module that does not have it as a dependency): go install github.com/superhuman/url64 should be equivalent to go install github.com/superhuman/url64@latest

This gives you the same behaviour as following the instructions in the current error messages, automatically.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions