github.com/amylindburg/docker@v1.7.0/hack/make/validate-vet (about)

     1  #!/bin/bash
     2  
     3  source "${MAKEDIR}/.validate"
     4  
     5  IFS=$'\n'
     6  files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' || true) )
     7  unset IFS
     8  
     9  errors=()
    10  for f in "${files[@]}"; do
    11  	# we use "git show" here to validate that what's committed passes go vet
    12  	failedVet=$(go vet "$f")
    13  	if [ "$failedVet" ]; then
    14  		errors+=( "$failedVet" )
    15  	fi
    16  done
    17  
    18  
    19  if [ ${#errors[@]} -eq 0 ]; then
    20  	echo 'Congratulations!  All Go source files have been vetted.'
    21  else
    22  	{
    23  		echo "Errors from go vet:"
    24  		for err in "${errors[@]}"; do
    25  			echo " - $err"
    26  		done
    27  		echo
    28  		echo 'Please fix the above errors. You can test via "go vet" and commit the result.'
    29  		echo
    30  	} >&2
    31  	false
    32  fi