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

lfaoro opened this issue May 14, 2019 · 2 comments

cmd/go: flow for easy upstream contributions #32042

lfaoro opened this issue May 14, 2019 · 2 comments


Copy link

@lfaoro 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.


This comment has been minimized.

Copy link

@agnivade agnivade commented May 15, 2019

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.


This comment has been minimized.

Copy link

@lfaoro 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 May 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.