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: cmd/go: get: behavior with replaced packages #66269

Open
janisz opened this issue Mar 12, 2024 · 4 comments
Open

proposal: cmd/go: get: behavior with replaced packages #66269

janisz opened this issue Mar 12, 2024 · 4 comments

Comments

@janisz
Copy link

janisz commented Mar 12, 2024

Proposal Details

Introduction:

The current behavior of go get -u PKG does not adequately handle packages that have been replaced in the go.mod file. This proposal aims to improve the user experience by providing clearer information when a replaced package is encountered during the go get -u operation.

Details:

When a user runs go get -u PKG and PKG has a replacement specified in the go.mod file, the go get command currently does not download the latest version of PKG.

Proposed Enhancement:

Modify the behavior of go get -u to detect when a package has been replaced in the go.mod file.
If PKG is replaced, display a clear message to the user indicating that PKG is not updated due to the replacement.
Provide guidance to the user, suggesting they check the go.mod file for the replacement settings.
Ideally, include a link to documentation that explains how to update replaces in the go.mod file.
The message displayed to the user should be informative and actionable, helping them understand why PKG was not updated and what steps they can take to resolve the issue.

The link provided in the message should direct users to relevant documentation that explains the concept of replaces in the go.mod file and provides instructions on updating them.

Impact:

Improved user experience: Users will receive clearer feedback when attempting to update replaced packages, reducing confusion and frustration.
Better understanding of go.mod functionality: Users will be guided to documentation that helps them understand and manage replaces in the go.mod file.

@gopherbot gopherbot added this to the Proposal milestone Mar 12, 2024
@janisz janisz changed the title proposal: go ge: behavior with replaced packages proposal: go get: behavior with replaced packages Mar 12, 2024
@ianlancetaylor ianlancetaylor added the GoCommand cmd/go label Mar 12, 2024
@ianlancetaylor ianlancetaylor changed the title proposal: go get: behavior with replaced packages proposal: cmd/go: get: behavior with replaced packages Mar 12, 2024
@meling
Copy link

meling commented Mar 12, 2024

Better yet, the output could suggest the command: go mod edit -replace. Similar to how git sometimes suggest what you might want to do next. I prefer not to have to lookup in the docs for such things.

@matloob
Copy link
Contributor

matloob commented Apr 4, 2024

@janisz What do you suggest happens when a user runs go get all or another pattern that matches multiple packges? Would you want to print an error message for each replaced package? That could get very cluttered.

@janisz
Copy link
Author

janisz commented Apr 5, 2024

Would you want to print an error message for each replaced package?

That's a good point! I think we should print this info for every replaced package that is updated. So you can see that package version has changed in go.mod but it has no effect because it's replaced.

@matloob
Copy link
Contributor

matloob commented Apr 16, 2024

I think it's reasonable that if there was a replacement such as replace golang.org/x/tools => ../../tools, when we run go get -u golang.org/x/tools after we print the message (for example) go: upgraded golang.org/x/tools v0.17.0 => v0.20.0 we also print something like go: golang.org/x/tools is replaced at all versions so upgrade may not apply to builds from this module.

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

6 participants