2015-04-01 00:48:03 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
2015-04-14 12:43:33 -04:00
|
|
|
source "${MAKEDIR}/.validate"
|
2015-04-01 00:48:03 -04:00
|
|
|
|
|
|
|
IFS=$'\n'
|
|
|
|
files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' || true) )
|
|
|
|
unset IFS
|
|
|
|
|
2015-04-13 14:31:17 -04:00
|
|
|
errors=()
|
2015-04-01 00:48:03 -04:00
|
|
|
for f in "${files[@]}"; do
|
2015-04-13 14:31:17 -04:00
|
|
|
failedVet=$(go vet "$f")
|
|
|
|
if [ "$failedVet" ]; then
|
|
|
|
errors+=( "$failedVet" )
|
|
|
|
fi
|
2015-04-01 00:48:03 -04:00
|
|
|
done
|
|
|
|
|
2015-04-13 14:31:17 -04:00
|
|
|
|
|
|
|
if [ ${#errors[@]} -eq 0 ]; then
|
|
|
|
echo 'Congratulations! All Go source files have been vetted.'
|
2015-04-01 00:48:03 -04:00
|
|
|
else
|
2015-04-13 14:31:17 -04:00
|
|
|
{
|
|
|
|
echo "Errors from go vet:"
|
|
|
|
for err in "${errors[@]}"; do
|
|
|
|
echo " - $err"
|
|
|
|
done
|
|
|
|
echo
|
|
|
|
echo 'Please fix the above errors. You can test via "go vet" and commit the result.'
|
|
|
|
echo
|
|
|
|
} >&2
|
|
|
|
false
|
2015-04-01 00:48:03 -04:00
|
|
|
fi
|