github.com/bdwilliams/libcompose@v0.3.1-0.20160826154243-d81a9bdacff0/script/validate-lint (about)

     1  #!/bin/bash
     2  
     3  source "$(dirname "$BASH_SOURCE")/.validate"
     4  
     5  # We will eventually get to the point where packages should be the complete list
     6  # of subpackages, vendoring excluded, as given by:
     7  #
     8  IFS=$'\n'
     9  files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/\|^integration' || true) )
    10  unset IFS
    11  
    12  errors=()
    13  for f in "${files[@]}"; do
    14  	# we use "git show" here to validate that what's committed passes go lint
    15  	failedLint=$(golint "$f")
    16  	if [ "$failedLint" ]; then
    17  		errors+=( "$failedLint" )
    18  	fi
    19  done
    20  
    21  if [ ${#errors[@]} -eq 0 ]; then
    22  	echo 'Congratulations!  All Go source files have been linted.'
    23  else
    24  	{
    25  		echo "Errors from golint:"
    26  		for err in "${errors[@]}"; do
    27  			echo "$err"
    28  		done
    29  		echo
    30  		echo 'Please fix the above errors. You can test via "golint" and commit the result.'
    31  		echo
    32  	} >&2
    33  	false
    34  fi