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: suggest 'go get' for packages in the main module instead of missing external package paths #46806

Open
bcmills opened this issue Jun 17, 2021 · 3 comments
Labels
BadErrorMessage Issues related compiler error messages that should be better. GoCommand cmd/go modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@bcmills
Copy link
Contributor

bcmills commented Jun 17, 2021

In #45979 (comment), I noted that go get in a go 1.17 module adds its arguments as // indirect.

As an intentional consequence of #45965, we place the // indirect dependencies in a separate section of the go.mod file from the direct dependencies. That potentially makes these new actually-direct dependencies more difficult to spot.

If we saw the import of the missing package from within the main module to begin with, we would add it without the erroneous // indirect marking, and avoid the churn of moving it between sections. So I think we should suggest a command that does that, instead of suggesting go get on the specific missing package(s).

That would also help to eliminate some of the redundancy in the go get hints (#43653).

CC @jayconrod @matloob @stevetraut

@bcmills bcmills added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. GoCommand cmd/go labels Jun 17, 2021
@bcmills bcmills added this to the Go1.18 milestone Jun 17, 2021
@bcmills bcmills self-assigned this Jun 17, 2021
@bcmills bcmills changed the title cmd/go: in errors for missing packages, suggest 'go get' on a package in the main module instead of the missing package itself cmd/go: suggest 'go get' for packages in the main module instead of missing external package paths Jun 17, 2021
@bcmills
Copy link
Contributor Author

bcmills commented Jun 17, 2021

This is closely related to #46710.

@bcmills bcmills modified the milestones: Go1.18, Go1.19 Nov 10, 2021
@ghost ghost deleted a comment Jan 10, 2022
@ghost ghost deleted a comment Jan 10, 2022
@bcmills bcmills modified the milestones: Go1.19, Go1.20 Jun 1, 2022
@bcmills bcmills modified the milestones: Go1.20, Go1.21 Dec 12, 2022
@bcmills
Copy link
Contributor Author

bcmills commented Jan 11, 2023

This would also avoid the case where we suggest go get on a package path, but the resulting go get command adds a module dependency that does not contain a package at its root (as in the example reported in #57473).

@gopherbot gopherbot modified the milestones: Go1.21, Go1.22 Aug 8, 2023
@bcmills bcmills modified the milestones: Go1.22, Backlog Feb 1, 2024
@bcmills bcmills added the BadErrorMessage Issues related compiler error messages that should be better. label Mar 15, 2024
@bcmills bcmills removed their assignment Mar 15, 2024
@bcmills
Copy link
Contributor Author

bcmills commented Mar 15, 2024

(CC @matloob @samthanawalla)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BadErrorMessage Issues related compiler error messages that should be better. GoCommand cmd/go modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

2 participants