hack/verify-golint.sh
4aa02424
 #!/bin/bash
 
 set -o errexit
 set -o pipefail
 
 if ! which golint &>/dev/null; then
   echo "Unable to detect 'golint' package"
   echo "To install it, run: 'go get github.com/golang/lint/golint'"
   exit 1
 fi
 
 GO_VERSION=($(go version))
 
17286387
 if [[ -z $(echo "${GO_VERSION[2]}" | grep -E 'go1.4') ]]; then
6406d71f
   echo "Unknown go version '${GO_VERSION}', skipping golint."
4aa02424
   exit 0
 fi
 
 OS_ROOT=$(dirname "${BASH_SOURCE}")/..
 source "${OS_ROOT}/hack/common.sh"
6f45c69b
 source "${OS_ROOT}/hack/util.sh"
4aa02424
 
 cd "${OS_ROOT}"
 
53664922
 arg="${1:-""}"
 bad_files=""
 
 if [ "$arg" == "-m" ]; then
   head=$(git rev-parse --short HEAD | xargs echo -n)
6406d71f
   set +e
   modified_files=$(git diff-tree --no-commit-id --name-only -r master..$head | \
53664922
     grep "^pkg" | grep ".go$" | grep -v "bindata.go$" | grep -v "Godeps" | \
6406d71f
     grep -v "third_party")
   if [ -n "${modified_files}" ]; then
     echo -e "Checking modified files: ${modified_files}\n"
     for f in $modified_files; do golint $f; done
     echo
   fi
   set -e
53664922
 else
6f45c69b
   bad_files=$(find_files | 
                 sort -u | 
                 sed 's/^.{2}//' | 
                 xargs -n1 printf "${GOPATH}/src/${OS_GO_PACKAGE}/%s\n" | 
                 xargs -n1 golint)
53664922
 fi
4aa02424
 
 if [[ -n "${bad_files}" ]]; then
   echo "golint detected following problems:"
   echo "${bad_files}"
   exit 1
 fi