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: flow for easy upstream contributions #32042

Closed
lfaoro opened this issue May 14, 2019 · 2 comments
Closed

cmd/go: flow for easy upstream contributions #32042

lfaoro opened this issue May 14, 2019 · 2 comments

Comments

@lfaoro
Copy link

lfaoro commented May 14, 2019

We often find ourselves using an upstream package which does most of what we need but not quite, so we decide to add a new feature to it and contribute the code upstream.

Before we can write any code we need to do some boring work:
• copy package path
• open browser
• paste URL
• fork package
• copy forked path
• go get fork path
• open go.mod
• add replace package path with canonical fork path
• now we can start editing

Would be nice to know if anyone found a smoother approach to easily contribute to upstream packages used in their codebase.

@agnivade
Copy link
Contributor

I don't think opening the browser, pasting a URL and pressing the fork button needs to be split into separate bullet points. Those are minuscule tasks. The real task is to edit the go.mod. You don't need to open go.mod and add the replace path manually. Just use go mod edit -replace=old=new for that.

The set of tasks basically are -

  • fork the package
  • go mod edit -replace=old=new
  • Start building. (The updated go.mod will automatically fetch the new package)

To update your package, you need to git clone it obviously, but that is a separate workflow.

If/when your patch has been accepted upstream, just use go mod edit -dropreplace. I think this is smooth and simple. If you have any specific suggestions to improve this further, please feel free to open separate issues for those.

cc @bcmills @jayconrod in case I have missed something.

@lfaoro
Copy link
Author

lfaoro commented May 15, 2019

Thank you very much @agnivade, the go mod edit -replace=old=new / go mod edit -dropreplace workflow is perfect.

@lfaoro lfaoro closed this as completed May 15, 2019
@golang golang locked and limited conversation to collaborators May 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants