Skip to content

Instantly share code, notes, and snippets.

@ericchiang
Last active August 29, 2015 14:08
Show Gist options
  • Save ericchiang/0124e06bff5479698826 to your computer and use it in GitHub Desktop.
Save ericchiang/0124e06bff5479698826 to your computer and use it in GitHub Desktop.
Some bash functions for go dependencies
# List all non-standard Go depencencies as a tree.
function gotree() {
level=${2:-'0'}
for package in `goimports $1`; do
printf "%${level}s$package\n"
gotree $package $[$level+2]
level=$[$level-2]
done
}
# List all non-standard Go dependencies.
function godeps() {
go list -f '{{join .Deps "\n"}}' $1 | \
xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}'
}
# List all go imports of a package.
function goimports() {
go list -f '{{join .Imports "\n"}}' $1 | \
xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment