Q: finding out which app imports the package of interest

104 views
Skip to first unread message

Peter A. Cejchan

unread,
Aug 8, 2012, 4:09:54 AM8/8/12
to golan...@googlegroups.com
Hi, folks

I would like to learn by example, so I think it would be nice to have a possibility to search through the code in the repositories
to see how the skilled people implement routine tasks. GoPkgDoc currently finds pkgs with specified import path, but not(?) those that import the specified pkg.
(a)  Is this a b ad idea?
(b)  Is there currently a way do do such a search?

Thanks, regards,
++pac

Aram Hăvărneanu

unread,
Aug 8, 2012, 5:32:02 AM8/8/12
to Peter A. Cejchan, golan...@googlegroups.com
What packages import go/ast directly or indirectly?

white:aram$ godep -p all | grep go/ast | cut -d' ' -f1
cmd/api
cmd/cgo
cmd/fix
cmd/go
cmd/godoc
cmd/gofmt
cmd/vet
exp/gotype
exp/types
go/ast
go/build
go/doc
go/parser
go/printer
code.google.com/p/goprotobuf/protoc-gen-go
code.google.com/p/goprotobuf/protoc-gen-go/generator
code.google.com/p/rbits/godep
github.com/davecheney/graphpkg
launchpad.net/gocheck
launchpad.net/juju-core/environs/dummy
launchpad.net/juju-core/environs/jujutest
launchpad.net/juju-core/state/testing
launchpad.net/juju-core/testing

What packages import go/ast directly?

white:aram$ godep all | grep go/ast | cut -d' ' -f1
cmd/api
go/ast
go/build
go/doc
go/parser
go/printer
cmd/cgo
cmd/fix
cmd/go
cmd/godoc
cmd/gofmt
cmd/vet
exp/gotype
exp/types
launchpad.net/gocheck

Which direct imports of cmd/fix cause it to import unicode/utf8?

$ godep cmd/fix | grep unicode/utf8 | cut -d' ' -f1 |
egrep `godep cmd/fix | grep cmd/fix |
sed -e 's/ /)|(/g' -e 's/^/(/g' -e 's/|($//g'`
bytes
fmt
strconv
go/ast
go/scanner
path/filepath
strings
go/printer
path
regexp
regexp/syntax

http://code.google.com/p/rbits/source/browse/godep/godep.demo

--
Aram Hăvărneanu

Peter A. Cejchan

unread,
Aug 8, 2012, 9:19:51 AM8/8/12
to golan...@googlegroups.com
Thanks, I've installed it, thanks!
However, I had a search for _uninstalled_  packages on my mind.
Best,
Peter.

Peter A. Cejchan

unread,
Aug 8, 2012, 9:45:58 AM8/8/12
to golan...@googlegroups.com

Peter A. Cejchan

unread,
Aug 9, 2012, 7:56:27 AM8/9/12
to golan...@googlegroups.com
Superb! I have found exactly what I wanted in a few minutes. A BIG THANK YOU !
Best,
++pac


On Thursday, 9 August 2012 03:01:08 UTC+2, gary b wrote:
I would like to learn by example, so I think it would be nice to have a possibility to search through the code in the repositories
to see how the skilled people implement routine tasks. GoPkgDoc currently finds pkgs with specified import path, but not(?) those that import the specified pkg. 

You can get the dependency graph for a snapshot of the GoPkgDoc dataset using the application example1.go @ https://gist.github.com/3094592.

An upcoming upgrade to GoPkgDoc will show dependent packages.

Reply all
Reply to author
Forward
Message has been deleted
0 new messages