Skip to content

Instantly share code, notes, and snippets.

@freeformz
Last active August 29, 2015 14:15
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 freeformz/2a458cb46419e5ed223b to your computer and use it in GitHub Desktop.
Save freeformz/2a458cb46419e5ed223b to your computer and use it in GitHub Desktop.
#!/bin/bash
# Display the packages that your code imports / depends on that
# are not in the go std lib.
result=()
#my deps
# NOTE: Requires jq
mine=($(go list -json | jq '.Imports + .Deps | .[]' | sort -u | sed -e 's/"//g'))
#stdlib
std=($(go list std))
inlist(){
item="${1}"
shift
declare -a list=("${@}")
for item2 in ${list[@]}; do
if [ "$item" == "${item2}" ]; then
return 0
fi
done
return 1
}
for item1 in ${mine[@]}; do
if ! inlist ${item1} ${std[@]} ; then
result+=($item1)
fi
done
for item in ${result[@]}; do
echo $item
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment