gohack
gohack copied to clipboard
accept package path in 'gohack get'
$ 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.
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,
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.