Description
This falls on the edge of proposal and question. I've been working with Go for a couple years now, but I'm still unsure what the recommended workflow is for forking a Go package and using that package in your code. I think documenting this workflow would enable so much more code sharing across the Go community.
To illustrate the problem, I've documented my experience report below as an "experienced gopher" trying to fork https://github.com/evanw/esbuild to expose the parser from internal/
:
I first tried https://godoc.org/golang.org/x/tools/cmd/gomvpkg to move a package and update the imports. This doesn't work with go modules yet.
Next, I googled around and learned about go mod edit
. I tried go mod edit -module $module
. This does rename my module, but not everything else.
I googled some more but kept finding old articles that either don't use go modules or use other package management tools like glide.
Then I thought that maybe go mod handles this automatically nowadays. So I just forked https://github.com/evanw/esbuild to https://github.com/matthewmueller/esbuild, then tried go get -u github.com/matthewmueller/esbuild
. This returns the following error:
go: github.com/matthewmueller/esbuild upgrade => v0.5.13
go get: github.com/matthewmueller/esbuild@v0.5.13: parsing go.mod:
module declares its path as: github.com/evanw/esbuild
but was required as: github.com/matthewmueller/esbuild
This is where I'm at right now. I guess I'll rename all of github.com/evanw/esbuild
to github.com/matthewmueller/esbuild
using find and replace. Then move internal/
to pkg/
. Since esbuild is a fast-moving project, I'll likely need to update this frequently and deal with merge conflicts each time.
I'd love to hear what others do. I'm happy to write something in the wiki once we figure out how to do this. If it's not currently possible, I'd be happy to help make this workflow better. Please let me know!