Skip to content

Instantly share code, notes, and snippets.

@mem
Last active June 2, 2016 21:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mem/99179b9e0d01e0b58f7b0c03666a511a to your computer and use it in GitHub Desktop.
Save mem/99179b9e0d01e0b58f7b0c03666a511a to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# Given a package's import path, this script will list the Go sources (not in $GOROOT)
# used to build that pacakge.
go list -f '{{ join .Deps "\n" }}' "$@" |
xargs -r -d '\n' \
go list -f '{{ if not .Goroot }}{{ .ImportPath }}{{ end }}' 2> /dev/null |
xargs -r -d '\n' \
go list \
-f '{{ $d := .Dir }}{{ range .GoFiles }}{{ $d }}/{{ . }}{{ "\n" }}{{ end }}' \
"$@" |
sort -u
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment