From f4834bbc323e70df4025b640d4df6448fbce13d0 Mon Sep 17 00:00:00 2001 From: Christoph Blecker Date: Tue, 21 Aug 2018 21:53:21 -0700 Subject: [PATCH] Fix golint command to only pass a single *.go file at a time --- hack/verify-golint.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/hack/verify-golint.sh b/hack/verify-golint.sh index f70f6c85f37..48a93b08b1a 100755 --- a/hack/verify-golint.sh +++ b/hack/verify-golint.sh @@ -71,10 +71,15 @@ errors=() not_failing=() for p in "${all_packages[@]}"; do # Run golint on package/*.go file explicitly to validate all go files - # 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"/*.go 2>/dev/null) + # and not just the ones for the current platform. This also will ensure that + # _test.go files are linted. + # Generated files are ignored, and each file is passed through golint + # individually, as if one file in the package contains a fatal error (such as + # a foo package with a corresponding foo_test package), golint seems to choke + # completely. + # Ref: https://github.com/kubernetes/kubernetes/pull/67675 + # Ref: https://github.com/golang/lint/issues/68 + failedLint=$(ls "$p"/*.go | egrep -v "(zz_generated.*.go|generated.pb.go|generated.proto|types_swagger_doc_generated.go)" | xargs -L1 golint 2>/dev/null) array_contains "$p" "${failing_packages[@]}" && in_failing=$? || in_failing=$? if [[ -n "${failedLint}" ]] && [[ "${in_failing}" -ne "0" ]]; then errors+=( "${failedLint}" )