2015-07-20 21:32:55 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
source "${MAKEDIR}/.validate"
|
|
|
|
|
2015-09-09 03:37:47 -04:00
|
|
|
IFS=$'\n'
|
2016-10-14 15:41:02 -04:00
|
|
|
files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' | grep -v '^api/types/' || true) )
|
2015-09-09 03:37:47 -04:00
|
|
|
unset IFS
|
2015-07-20 21:32:55 -04:00
|
|
|
|
|
|
|
errors=()
|
2015-09-09 03:37:47 -04:00
|
|
|
for f in "${files[@]}"; do
|
|
|
|
failedLint=$(golint "$f")
|
2015-07-20 21:32:55 -04:00
|
|
|
if [ "$failedLint" ]; then
|
2015-07-21 17:54:27 -04:00
|
|
|
errors+=( "$failedLint" )
|
2015-07-20 21:32:55 -04:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ ${#errors[@]} -eq 0 ]; then
|
|
|
|
echo 'Congratulations! All Go source files have been linted.'
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "Errors from golint:"
|
2015-07-21 17:54:27 -04:00
|
|
|
for err in "${errors[@]}"; do
|
|
|
|
echo "$err"
|
|
|
|
done
|
2015-07-20 21:32:55 -04:00
|
|
|
echo
|
|
|
|
echo 'Please fix the above errors. You can test via "golint" and commit the result.'
|
|
|
|
echo
|
|
|
|
} >&2
|
|
|
|
false
|
|
|
|
fi
|