gohack
gohack copied to clipboard
gohack of replaced modules does not work correctly
When a go.mod file already contains a replacement of one module by another (not a directory), gohack get -vcs checks out the original repository, not the current replacement. Also, gohack get (without -vcs) does check out the correct code, but puts it in the directory for the original module, not the replacement module, which is probably wrong.
For example, given this go.mod:
module example.com/foo
require gopkg.in/errgo.v2 v2.0.0
replace gopkg.in/errgo.v2 => github.com/rogpeppe/test2/arble v0.0.0-20181008213029-f6022c873160
If we run gohack get -vcs gopkg.in/errgo.v2, it checks out gopkg.in/errgo.v2 to $GOHACK/gopkg.in/errgo.v2, where we actually want it to check out github.com/rogpeppe/test2/arble to $GOHACK/github.com/rogpeppe/test2/arble and end up with a go.mod file like this:
module example.com/foo
require gopkg.in/errgo.v2 v2.0.0
replace gopkg.in/errgo.v2 => /home/rog/gohack/github.com/rogpeppe/test2/arble // was gopkg.in/errgo.v2 => github.com/rogpeppe/test2/arble v0.0.0-20181008213029-f6022c873160