diff --git a/hack/verify-govet.sh b/hack/verify-govet.sh index 3a6bf72d43b4..86ec58aefcaa 100755 --- a/hack/verify-govet.sh +++ b/hack/verify-govet.sh @@ -14,41 +14,39 @@ mkdir -p _output/govet os::build::setup_env vetexceptions=( - "pkg/auth/ldaputil/client.go:69: assignment copies lock value to c: crypto/tls.Config contains sync.Once contains sync.Mutex" + "pkg/auth/ldaputil/client.go:69: assignment copies lock value to c: crypto/tls.Config contains sync.Once contains sync.Mutex" ) -function is_vetexception() -{ - text=$1 - echo "checking ${text}" - for ve in "${vetexceptions[@]}" - do - if [[ ve == ${text} ]] - then - echo "returning true" - return 0 - fi - done - return 1 + +function is_vetexception() { + text=$1 + echo "checking ${text}" + for ve in "${vetexceptions[@]}"; do + if [[ "${ve}" = "${text}" ]]; then + echo "returning true" + return 0 + fi + done + return 1 } FAILURE=false test_dirs=$(find_files | cut -d '/' -f 1-2 | sort -u) -for test_dir in $test_dirs -do - result=$(go tool vet -shadow=false $test_dir) - if [ "$?" -ne 0 ] && [ ! is_vetexception "${result}" ] - then - FAILURE=true - fi +for test_dir in $test_dirs; do + if ! result="$( go tool vet -shadow=false "${test_dir}" )"; then + while read -r line; do + if ! is_vetexception "${line}"; then + FAILURE=true + fi + done <<<${result} + fi done # We don't want to exit on the first failure of go vet, so just keep track of # whether a failure occurred or not. -if $FAILURE -then - echo "FAILURE: go vet failed!" - exit 1 +if $FAILURE; then + echo "FAILURE: go vet failed!" + exit 1 else - echo "SUCCESS: go vet succeded!" - exit 0 + echo "SUCCESS: go vet succeded!" + exit 0 fi