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

cmd/go: warn if 'go install' is called on a non-main package pattern in module mode #46912

Open
bcmills opened this issue Jun 24, 2021 · 1 comment
Labels
GoCommand cmd/go modules NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@bcmills
Copy link
Contributor

bcmills commented Jun 24, 2021

This issue is a companion to proposal #41696, brought to my attention via https://stackoverflow.com/q/64462190.

In module mode, non-main packages lack an install target, and go install for such packages is equivalent to go build (compare #46911).

As such, a call to go install with a pattern containing only non-main packages is at best confusing: at best, the user has conflated go install with go build, and at worst, they are trying to install a binary but have named a corresponding library instead.

The latter case crops up surprisingly frequently. For example, the library golang.org/x/tools/imports is easily confused with the executable golang.org/x/tools/cmd/goimports, and the library github.com/gobuffalo/buffalo is easily confused with the executable github.com/gobuffalo/buffalo/buffalo.

I don't think we need to actually remove the ability to call go install on a non-main package, but we should at least log something to clear up the user's likely confusion.

CC @jayconrod @matloob

@bcmills bcmills added NeedsFix The path to resolution is known, but the work has not been done. modules labels Jun 24, 2021
@bcmills bcmills added this to the Backlog milestone Jun 24, 2021
@bcmills bcmills self-assigned this Jun 24, 2021
@bcmills bcmills modified the milestones: Backlog, Go1.18 Jun 24, 2021
@ianlancetaylor
Copy link
Contributor

@bcmills This is in the 1.18 milestone; time to move to 1.19? Thanks.

@bcmills bcmills modified the milestones: Go1.18, Backlog Jan 29, 2022
@bcmills bcmills removed their assignment Mar 15, 2024
@bcmills bcmills added the GoCommand cmd/go label Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand cmd/go modules NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

2 participants