mohanraj-r
2/23/2017 - 1:03 AM

Go commands

Go commands

# list dependencies of a package
# https://groups.google.com/forum/#!topic/golang-nuts/611QEJqkDKw
go list -f {{.Deps}} # Top level deps only
go list -f {{.Deps}} ... # All deps recursively

# List external depencies of a package
# https://dave.cheney.net/2014/09/14/go-list-your-swiss-army-knife
function godep {
    pushd $1
    printf '\nDirect imports\n'
    go list -f '{{join .Imports "\n"}}'
    printf '\n\nTest Imports\n'
    go list -f '{{join .TestImports "\n"}}'
    printf '\n\nXTest Imports\n'
    go list -f '{{join .XTestImports "\n"}}'
    printf '\n\nAll dependencies\n'
    go list -f '{{join .Deps "\n"}}' | less --quit-if-one-screen
    popd
}