gohack
gohack copied to clipboard
Use existing dependency code source from the GOPATH
gohack should check if the dependency already exists in the GOPATH before cloning it into $HOME/gohack.
Let's say I have github.com/heetch/felice in my GOPATH.
Instead of having:
replace github.com/heetch/felice => $HOME/gohack/github.com/heetch/felice
I would have
replace github.com/heetch/felice => $GOPATH/src/github.com/heetch/felice
Do people still actively use GOPATH when developing code, though? I personally do all of my development in modules nowadays, and I expect GOPATH will be dropped in a couple of Go releases once modules are on by default.
I think that there is still people that didn't move at all to modules.
But maybe if we don't want to take the GOPATH in account anymore we can pass a flag that specifies in which directory to look for before cloning the dependency. What do you think?
Do people still actively use GOPATH when developing code, though?
Old habits die hard.
Also, I sometimes want to download code to poke around at it before I have an actual use for it anywhere. I currently put those things in my GOPATH.
For control over the location of where gohack puts code, set GOHACK.
FWIW - I always find myself doing GOHACK=$(mktemp -d), because more often than not I'm simply poking around code.