github.com/zcqzcg/fabric-ca@v2.0.0-alpha.0.20200416163940-d878ee6db75a+incompatible/scripts/check_imports (about) 1 #!/bin/bash 2 # 3 # Copyright IBM Corp. All Rights Reserved. 4 # 5 # SPDX-License-Identifier: Apache-2.0 6 # 7 8 # shellcheck source=/dev/null 9 source "$(cd "$(dirname "$0")" && pwd)/functions.sh" 10 11 fabric_ca_dir="$(cd "$(dirname "$0")/.." && pwd)" 12 source_dirs=() 13 while IFS=$'\n' read -r source_dir; do 14 source_dirs+=("$source_dir") 15 done < <(go list -f '{{.Dir}}' ./... | sed s,"${fabric_ca_dir}".,,g | cut -f 1 -d / | sort -u) 16 17 echo "Checking imports ..." 18 OUTPUT="$(goimports -l "${source_dirs[@]}")" 19 OUTPUT="$(filterExcludedAndGeneratedFiles "$OUTPUT")" 20 if [[ "$OUTPUT" != "" ]]; then 21 echo "The following files have import problems:" 22 echo "$OUTPUT" 23 echo "You may run 'goimports -w <file>' to fix each file." 24 exit 1 25 fi 26 echo "All files are properly formatted"