Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imply module name from $PWD #71

Open
stapelberg opened this issue May 29, 2020 · 5 comments
Open

Imply module name from $PWD #71

stapelberg opened this issue May 29, 2020 · 5 comments

Comments

@stapelberg
Copy link

-*- mode: compilation; default-directory: "~/go/pkg/mod/github.com/stapelberg/glog@v0.0.0-20160603071839-f15f13b47694/" -*-
Compilation started at Fri May 29 21:53:41

goversion -m $(which gohack) && gohack get
/home/michael/go/bin/gohack go1.14
	path  github.com/rogpeppe/gohack
	mod   github.com/rogpeppe/gohack       v1.0.2
	dep   github.com/rogpeppe/go-internal  v1.0.0
	dep   golang.org/x/tools               v0.0.0-20180917221912-90fa682c2a6e
	dep   gopkg.in/errgo.v2                v2.1.0
cannot determine main module: go list -m: not using modules

Compilation exited abnormally with code 1 at Fri May 29 21:53:41

I have to use gohack get github.com/stapelberg/glog even though it’s obvious from my working directory which package I mean.

Would a PR for this be accepted?

@stapelberg
Copy link
Author

Forgot to mention: of course the module cache can’t (and shouldn’t) be modified, so strictly speaking this only makes sense with gohack get -vcs, I suppose.

@rogpeppe
Copy link
Owner

Sorry, I don't understand. What's your working directory? What would you expect to happen?

@stapelberg
Copy link
Author

The working directory is e.g. ~/go/pkg/mod/github.com/stapelberg/glog@v0.0.0-20160603071839-f15f13b47694/, i.e. the module cache. This is where the “Go to definition” feature takes me when working with modules.

I expect gohack get to check out the module in whose cached version I’m working without having to repeat its name on the command line, e.g.:

cd ~/go/pkg/mod/github.com/stapelberg/glog@v0.0.0-20160603071839-f15f13b47694/
gohack get -vcs
cd ~/gohack/github.com/stapelberg/glog

@rogpeppe
Copy link
Owner

rogpeppe commented Jun 2, 2020

One of the main things that gohack does is to update the go.mod file of the current module. Given that the go.mod file of your module in this case is not editable, what would you expect to happen in this case?

@stapelberg
Copy link
Author

I would have expected gohack to check out the VCS repository into ~/gohack/github.com/stapelberg/glog.

I understand that this is not the main thing gohack does, but it’s something that it does. In a way, I treat it as a go get replacement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants