Skip to content
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

proposal: go install: allow whitespace delimited package names from separate modules and versions #59549

Open
mcandre opened this issue Apr 11, 2023 · 2 comments
Milestone

Comments

@mcandre
Copy link

mcandre commented Apr 11, 2023

I would like to be able to run:

go install \
	github.com/alexkohler/nakedret@v1.0.1 \
	github.com/kisielk/errcheck@v1.6.3 \
	github.com/magefile/mage@v1.14.0 \
	github.com/mcandre/factorio/cmd/factorio@v0.0.3 \
	golang.org/x/lint/golint@latest \
	golang.org/x/tools/cmd/goimports@latest \
	golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@latest \
	honnef.co/go/tools/cmd/staticcheck@2023.1.3

go mod tidy

Like I can with other common package managers (apt, yum, brew, cargo).

However, Go currently has this policy prohibiting this invocation. So I have to instead write down the same package commands in a longer boilerplate:

go install github.com/alexkohler/nakedret@v1.0.1
go install github.com/kisielk/errcheck@v1.6.3
go install github.com/magefile/mage@v1.14.0
go install github.com/mcandre/factorio/cmd/factorio@v0.0.3
go install golang.org/x/lint/golint@latest
go install golang.org/x/tools/cmd/goimports@latest
go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@latest
go install honnef.co/go/tools/cmd/staticcheck@2023.1.3

go mod tidy

Can we please remove the current restriction against asking go install to request separate modules and versions per run?

No, I don't want to use an alias or other shim. That introduces fragility and vendor locks provisioning scripts.

When go mod eventually standardizes built-in support for pinning dev dependencies, then that would somewhat mitigate the need for this feature in go install. But this feature would still serve as a good complement to go mod, regardless.

@gopherbot gopherbot added this to the Proposal milestone Apr 11, 2023
@ianlancetaylor ianlancetaylor added the GoCommand cmd/go label Apr 11, 2023
@ianlancetaylor
Copy link
Contributor

CC @bcmills @matloob

@mvdan
Copy link
Member

mvdan commented Apr 22, 2023

Note that installing multiple packages from different modules in a single command is not the same as doing it via separate commands. Each go install or go build invocation results in a single build context, i.e. a single MVS resolution to find all modules to download and packages to build.

I personally run many go install pkg@latest & commands and then wait for all of them. This doesn't mix their dependency versions via MVS, the concurrency works fine thanks to file locking in the build cache, and I don't really notice the overhead of running cmd/go many times.

Agreed that the UX is perhaps not great, but the current restriction is there for a good reason, and lifting it without a second thought will cause confusion and unintended consequences.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Incoming
Development

No branches or pull requests

4 participants