From 42203b366d21e2e716573eea09c7b8faad98f6e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Thu, 10 May 2018 20:51:24 +0200 Subject: [PATCH] Run (go vet) on all subpackages instead only of changed files Apparently, it was never documented to use (go vet $somefile.go) (but (go tool vet $somefile.go) was). go 1.10 seems to do more checks within packages, and $somefile.go is interpreted as a package with only that file (even if other files from that package are in the same directory), leading to spurious "undefined: $symbol" errors. So, just run (go vet) on ./... (explicitly excluding skopeo/vendor for the benefit of Go 1.8). We only have three subpackages, so the savings, if any, from running (go vet) only on the modified subpackages would be small. More importantly, on a toolchain update, ./... allows us to see the newly detected issues all at once, instead of randomly waiting for a commit that changes one of the affected files for the failure to show up. --- hack/make/validate-vet | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/hack/make/validate-vet b/hack/make/validate-vet index 39f4a2c1..f95d0fc8 100755 --- a/hack/make/validate-vet +++ b/hack/make/validate-vet @@ -1,28 +1,13 @@ #!/bin/bash -source "$(dirname "$BASH_SOURCE")/.validate" +errors=$(go vet $(go list -e ./... | grep -v "$SKOPEO_PKG"/vendor)) -IFS=$'\n' -files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' || true) ) -unset IFS - -errors=() -for f in "${files[@]}"; do - failedVet=$(go vet "$f") - if [ "$failedVet" ]; then - errors+=( "$failedVet" ) - fi -done - - -if [ ${#errors[@]} -eq 0 ]; then +if [ -z "$errors" ]; then echo 'Congratulations! All Go source files have been vetted.' else { echo "Errors from go vet:" - for err in "${errors[@]}"; do - echo " - $err" - done + echo "$errors" echo echo 'Please fix the above errors. You can test via "go vet" and commit the result.' echo