打包:从fork提交PR时,如何避免“找不到包”错误?

I am running into what sounds like a limitation in an overall simple approach for integrating git with go install.

  1. I've forked a git repo on github
  2. I now have to deal with changing packages in the same repo to reference correctly my own fork.
  3. Then when I am ready to submit a PR, I need to revert the package imports while I won't be able to compile and install the changes.
  4. I could keep 2 repos and cherry pick the lines I need to change but that seems too complicated by 2016.

How do I get around this problem?

You might have forked github.com/user1/goproject into github.com/user2/goproject, that does not mean you cannot clone it wherever you want in your GOPATH.

In particular, you can clone it in:

$GOPATH
  github.com
    user1
      goproject

You effectively are replacing the local clone of the original repo by the clone of your fork.

That means locally, you don't change any package path, even though git remote -v tells you are are pushing back to your fork url github.com/user2/goproject.