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: `go get` automatically add `replace` in go.mod #39185

Open
XSAM opened this issue May 21, 2020 · 1 comment
Open

proposal: cmd/go: `go get` automatically add `replace` in go.mod #39185

XSAM opened this issue May 21, 2020 · 1 comment

Comments

@XSAM
Copy link
Contributor

@XSAM XSAM commented May 21, 2020

Scenario

B repo fork from the A repo and B repo add some codes that A repo doesn't have.

Try to import B in C with go mod.

go get B

Go will compliant and refuse to import B.

module declares its path as: A
        but was required as: B

Because of B fork from A, it is no way to rename all the import paths which relevant to A since it will break the dependency.

And those users of B are painful to import B to their project, since go get refuse to import B, and they have to modify the go.mod by themselves.

For example:

go mod edit -replace A@latest=B@latest

It's like B is a second-class citizen.

Proposal

I propose that go get can handle this scenario by add replace in go.mod and not refuse to import such repo.

Or maybe we can add a new flag go get -r to declare that the user wants to add a replacement explicitly.

Also, currently, go get -u refuse to upgrade B repo even we already add replace in go.mod. Therefore I think go get -u should respect this if this proposal passed.

@gopherbot gopherbot added this to the Proposal milestone May 21, 2020
@gopherbot gopherbot added the Proposal label May 21, 2020
@ianlancetaylor ianlancetaylor changed the title proposal: `go get` automatically add `replace` in go.mod proposal: cmd/go: `go get` automatically add `replace` in go.mod May 21, 2020
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented May 21, 2020

@rsc rsc added this to Incoming in Proposals Jun 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Proposals
Incoming
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.