2015-07-20 21:32:55 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
source "${MAKEDIR}/.validate"
|
|
|
|
|
2015-09-04 08:56:45 -04:00
|
|
|
packages=( $(go list ./... 2> /dev/null | grep -vE "^github.com/docker/docker/vendor|^github.com/docker/docker/autogen" || true ) )
|
2015-07-20 21:32:55 -04:00
|
|
|
|
|
|
|
errors=()
|
2015-07-21 17:54:27 -04:00
|
|
|
for p in "${packages[@]}"; do
|
2015-09-04 08:56:45 -04:00
|
|
|
# Remove the github.com/docker/docker/ prefix from listed package
|
|
|
|
package="${p#github.com/docker/docker/}"
|
2015-07-22 13:11:00 -04:00
|
|
|
# Run golint on package/*.go file explicitly to validate all go files
|
|
|
|
# and not just the ones for the current platform.
|
2015-09-04 08:56:45 -04:00
|
|
|
failedLint=$(golint $package/*.go)
|
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
|