2017-02-01 00:45:59 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
source "${MAKEDIR}/.validate"
|
|
|
|
|
|
|
|
IFS=$'\n'
|
|
|
|
files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' || true) )
|
|
|
|
unset IFS
|
|
|
|
|
|
|
|
errors=()
|
|
|
|
for f in "${files[@]}"; do
|
2017-03-28 19:56:09 +00:00
|
|
|
failedLint=$(golint "$f")
|
2017-02-01 00:45:59 +00:00
|
|
|
if [ "$failedLint" ]; then
|
|
|
|
errors+=( "$failedLint" )
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ ${#errors[@]} -eq 0 ]; then
|
|
|
|
echo 'Congratulations! All Go source files have been linted.'
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "Errors from golint:"
|
|
|
|
for err in "${errors[@]}"; do
|
|
|
|
echo "$err"
|
|
|
|
done
|
|
|
|
echo
|
|
|
|
echo 'Please fix the above errors. You can test via "golint" and commit the result.'
|
|
|
|
echo
|
|
|
|
} >&2
|
|
|
|
false
|
|
|
|
fi
|