github.com/olljanat/moby@v1.13.1/hack/validate/lint (about)

     1  #!/bin/bash
     2  
     3  export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
     4  source "${SCRIPTDIR}/.validate"
     5  
     6  IFS=$'\n'
     7  files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' | grep -v '^api/types/container/' | grep -v '^cli/compose/schema/bindata.go' || true) )
     8  unset IFS
     9  
    10  errors=()
    11  for f in "${files[@]}"; do
    12  	failedLint=$(golint "$f")
    13  	if [ "$failedLint" ]; then
    14  		errors+=( "$failedLint" )
    15  	fi
    16  done
    17  
    18  if [ ${#errors[@]} -eq 0 ]; then
    19  	echo 'Congratulations!  All Go source files have been linted.'
    20  else
    21  	{
    22  		echo "Errors from golint:"
    23  		for err in "${errors[@]}"; do
    24  			echo "$err"
    25  		done
    26  		echo
    27  		echo 'Please fix the above errors. You can test via "golint" and commit the result.'
    28  		echo
    29  	} >&2
    30  	false
    31  fi