gohack icon indicating copy to clipboard operation
gohack copied to clipboard

Use existing dependency code source from the GOPATH

Open yaziine opened this issue 6 years ago • 4 comments

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

yaziine avatar Jul 11 '19 04:07 yaziine

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.

mvdan avatar Jul 11 '19 04:07 mvdan

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?

yaziine avatar Jul 12 '19 01:07 yaziine

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.

josharian avatar Sep 30 '19 17:09 josharian

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.

myitcv avatar Oct 01 '19 14:10 myitcv