Any tool to show what packages made it into a Go executable?

422 views
Skip to first unread message

Tim K

unread,
Mar 11, 2016, 10:36:05 AM3/11/16
to golang-nuts
Is there any tool that can analyze an executable produced by 'go build' or 'go install' and show all Go packages that got linked into the executable?

Thanks.

Tim

Tim K

unread,
Mar 11, 2016, 1:19:12 PM3/11/16
to golang-nuts
I should add that I'm aware of "go build -v", but what if you already have the executable? Is this info available in Go executables?

andrey mirtchovski

unread,
Mar 11, 2016, 1:28:17 PM3/11/16
to Tim K, golang-nuts
if you do 'go tool nm <your go binary>' you will get a list of all the
defined functions and the packages they come from. you can filter from
there.
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Tim K

unread,
Mar 11, 2016, 2:00:52 PM3/11/16
to golang-nuts, tim....@gmail.com
Thank you. This is very useful.

Marvin Stenger

unread,
Mar 11, 2016, 2:04:18 PM3/11/16
to golang-nuts, tim....@gmail.com
go tool nm <your go binary> | cut -d ' '  -f 5 | sed -e  's/\..*$//' | sort -u
Worked for me.
Reply all
Reply to author
Forward
0 new messages