Skip to content

Instantly share code, notes, and snippets.

@ericlathrop
Last active December 19, 2015 05:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericlathrop/5906365 to your computer and use it in GitHub Desktop.
Save ericlathrop/5906365 to your computer and use it in GitHub Desktop.
A description of problems working with forked repositories in Go.

Say there's a Go app at github.com/supermighty/app, which has a package a that references b. If I fork that repository to github.com/ericlathrop/app, now the local file $GOPATH/github.com/ericlathrop/app/a/something.go still has the line

import ("github.com/supermighty/app/b")

so when I edit $GOPATH/github.com/ericlathrop/app/b/something.go, my changes are never seen in a because it's still using the original copy of b!

The workaround is to symlink the original repository path to the fork's path:

rm -rf $GOPATH/github.com/supermighty/a
ln -s $GOPATH/github.com/ericlathrop/a $GOPATH/github.com/supermighty/a

This lets you avoid having to rewrite all the import URLs, and revert them when your pull request is merged in.

@nathany
Copy link

nathany commented Jul 2, 2013

Nice solution. I linked it from this Google Doc

An alternative would be to use a tool to rewrite the imports on a branch that your team uses but does not send a pull request for. See https://groups.google.com/forum/#!topic/golang-nuts/ONs1vjIm9kg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment