Last active
August 29, 2015 14:08
-
-
Save ericchiang/0124e06bff5479698826 to your computer and use it in GitHub Desktop.
Some bash functions for go dependencies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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