2015-07-21 01:32:55 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2016-10-12 19:25:49 +00:00
|
|
|
export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
source "${SCRIPTDIR}/.validate"
|
2015-07-21 01:32:55 +00:00
|
|
|
|
2015-09-09 07:37:47 +00:00
|
|
|
IFS=$'\n'
|
2016-11-04 02:06:21 +00:00
|
|
|
files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' | grep -v '^api/types/container/' || true) )
|
2015-09-09 07:37:47 +00:00
|
|
|
unset IFS
|
2015-07-21 01:32:55 +00:00
|
|
|
|
|
|
|
errors=()
|
2015-09-09 07:37:47 +00:00
|
|
|
for f in "${files[@]}"; do
|
|
|
|
failedLint=$(golint "$f")
|
2015-07-21 01:32:55 +00:00
|
|
|
if [ "$failedLint" ]; then
|
2015-07-21 21:54:27 +00:00
|
|
|
errors+=( "$failedLint" )
|
2015-07-21 01:32:55 +00: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 21:54:27 +00:00
|
|
|
for err in "${errors[@]}"; do
|
|
|
|
echo "$err"
|
|
|
|
done
|
2015-07-21 01:32:55 +00:00
|
|
|
echo
|
|
|
|
echo 'Please fix the above errors. You can test via "golint" and commit the result.'
|
|
|
|
echo
|
|
|
|
} >&2
|
|
|
|
false
|
|
|
|
fi
|