#!/bin/bash

set -e -o pipefail

bin=$(dirname $0)

set +e # golint will fail on the issues we filter out
errors=$(
  $bin/gofiles $bin/env go run golang.org/x/lint/golint \
    | grep -v                                           \
     -e 'should have comment.* or be unexported'        \
     -e '/mocks/'                                       \
     -e '/fakes/'                                       \
     -e '/jobsfakes/'                                   \
     -e 'should not be capitalized'                     \
     -e 'underscore in package name'                    \
     -e 'bootstrapper/spec/'                            \
     -e 'jobsupervisor/pipe/syslog/syslog.go'           \
     -e 'platform/windows_platform_test.go'             \
     -e 'platform/syscall_windows.go'                   \
     -e 'jobsupervisor/winsvc'
)
set -e

if [ "$(echo -n "$errors")" != "" ]; then
  echo "$errors"
  exit 1
fi
