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 <mark.d.horn@intel.com>
This commit is contained in:
Mark D Horn
2019-04-16 22:56:16 -07:00
committed by Mark Horn
parent 685ae93433
commit d62ef607aa
+21
View File
@@ -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