gohack icon indicating copy to clipboard operation
gohack copied to clipboard

accept package path in 'gohack get'

Open josharian opened this issue 6 years ago • 2 comments

$ gohack get -vcs github.com/rogpeppe/go-internal/modfile
module "github.com/rogpeppe/go-internal/modfile" does not appear to be in use
all modules failed; not replacing anything

The module is github.com/rogpeppe/go-internal. But the intent of the command was clear: I want to look at the package github.com/rogpeppe/go-internal/modfile. gohack get should accept a package path and start hacking on the containing module.

josharian avatar Oct 02 '19 17:10 josharian

Somewhere in cmd/go there must be a method that maps import paths to their containing modules. But I can't find it. I'm happy to work on implementing this if anyone can point me to that.

josharian avatar Oct 02 '19 17:10 josharian

@josharian,

go list -f '{{with .Module}}{{.Path}}{{end}}' github.com/rogpeppe/go-internal/modfile

will give you the module containing package github.com/rogpeppe/go-internal/modfile.

bcmills avatar Oct 02 '19 18:10 bcmills