Skip to content

Commit

Permalink
Ensure golint binary exists before linting
Browse files Browse the repository at this point in the history
  • Loading branch information
TommyLike committed Mar 18, 2019
1 parent efabe0b commit 59da88d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion hack/verify-golint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ source "${KUBE_ROOT}/hack/lib/init.sh"

kube::golang::verify_go_version

if ! which golint > /dev/null; then
echo 'Can not find golint, install with:'
echo 'go get -u github.com/golang/lint/golint'
exit 1
fi

cd "${KUBE_ROOT}"

array_contains () {
Expand Down Expand Up @@ -54,7 +60,7 @@ for p in "${all_packages[@]}"; do
# and not just the ones for the current platform.
# Packages with a corresponding foo_test package will make golint fail
# with a useless error. Just ignore that, see golang/lint#68.
failedLint=$(golint "$p" 2>/dev/null)
failedLint=$(golint "$p"/*.go 2>/dev/null)
array_contains "$p" "${failing_packages[@]}" && in_failing=$? || in_failing=$?
if [[ -n "${failedLint}" ]] && [[ "${in_failing}" -ne "0" ]]; then
errors+=( "${failedLint}" )
Expand Down

0 comments on commit 59da88d

Please sign in to comment.