Skip to content

Instantly share code, notes, and snippets.

@nilium
Created March 27, 2019 15:49
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 nilium/92ba49be56a8c2cedb82f509a69ae2e5 to your computer and use it in GitHub Desktop.
Save nilium/92ba49be56a8c2cedb82f509a69ae2e5 to your computer and use it in GitHub Desktop.
Short script to list all non-stdlib sources used by a Go package
#!/usr/bin/env bash
comm -23 \
<(go list -f '{{.ImportPath}}{{"\n"}}{{range .Deps}}{{.}}{{"\n"}}{{end}}' "$@" | sort | uniq) \
<(go list std | sort) |
xargs go list -f '{{$dir := .Dir}}{{range .GoFiles}}{{$dir}}/{{.}}{{"\n"}}{{end}}' |
sort | uniq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment