Skip to content

Instantly share code, notes, and snippets.

@arya
Last active January 17, 2018 22:58
Show Gist options
  • Save arya/c297b58170169fad09c3b3c63da8feef to your computer and use it in GitHub Desktop.
Save arya/c297b58170169fad09c3b3c63da8feef to your computer and use it in GitHub Desktop.
#!/bin/bash
set -o errexit -o nounset -o pipefail
package=$1
package_dir=$(go list -f '{{.Dir}}' ${package})
pushd ${package_dir} > /dev/null
git_root=$(git rev-parse --show-toplevel)
pushd ${git_root} > /dev/null
dep_packages=$(go list -f '{{join .Deps "\n"}}' ${package} | xargs go list -f '{{if not .Standard}}{{.Dir}}{{end}}')
repo_packages=""
for dep in ${dep_packages}; do
if [[ "${dep}" == "${git_root}/"* ]]; then
repo_packages+="${dep} "
fi
done
echo ${repo_packages}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment