-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
Wiki: document how to fork a package and use that fork in your project #39889
Comments
Update: It turns out go mod does handle this automatically nowadays! While I'm still not sure why |
I think if you changed |
Thanks for the response @melbahja. I've tried that and wasn't able to get it working. Same errors:
I'm also no longer able to use
What does required mean in this case? Required by |
I found it! And it is pretty much documented already! It works without messing with the fork's go.mod or imports, which is really neat. https://github.com/golang/go/wiki/Modules#when-should-i-use-the-replace-directive
Then you just run You need the
Also, I guess the wiki is public, hah. I just added the following note:
Closing. Working as expected and documented. |
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 triedgo 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:This is where I'm at right now. I guess I'll rename all of
github.com/evanw/esbuild
github.com/matthewmueller/esbuild
using find and replace. Then moveinternal/
topkg/
. 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!
The text was updated successfully, but these errors were encountered: