From d62ef607aa52806bc0375425da978e7a7ef441fc Mon Sep 17 00:00:00 2001 From: Mark D Horn Date: Tue, 16 Apr 2019 16:21:46 -0700 Subject: [PATCH] Script for show all imports We use this to review the imported packages are part of our release review process. Signed-off-by: Mark D Horn --- scripts/dump_imports.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 scripts/dump_imports.sh diff --git a/scripts/dump_imports.sh b/scripts/dump_imports.sh new file mode 100755 index 0000000..29082c1 --- /dev/null +++ b/scripts/dump_imports.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +OUTPUT=$(mktemp) + +# Change to the top level git directory to get all of the source files +cd $(git rev-parse --show-toplevel) + +# List all of the go source files (committed) +for file in $(git ls-files | grep -v '^vendor' | grep -v '^tests' | grep '.go$') +do + # echo "$file" + # append all of the imports for the go file, one per line to the composite file + go list -f '{{ join .Imports "\n" }}' $file >> ${OUTPUT} +done + +# Remove the imports for our own code +grep -v '^github.com/clearlinux/clr-installer' ${OUTPUT} | sort | uniq + +rm -f ${OUTPUT} + +exit 0