Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions misc/git/hooks/golangci-lint
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@

gofiles=$(git diff --cached --name-only --diff-filter=ACM | grep '^go/.*\.go$' | grep -v '^go/vt/proto/' | grep -v 'go/vt/sqlparser/sql.go')

# xargs -n1 because dirname on MacOS does not support multiple arguments.
gopackages=$(echo $gofiles | xargs -n1 dirname | sort -u)

GOLANGCI_LINT=$(command -v golangci-lint >/dev/null 2>&1)
if [ $? -eq 1 ]; then
echo "Downloading golangci-lint..."
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.27.0
fi

#golangci-lint run --disable=ineffassign,unused,gosimple,staticcheck,errcheck,structcheck,varcheck,deadcode
for gofile in $gofiles
for gopackage in $gopackages
do
golangci-lint run --disable=errcheck --timeout=10m $gofile
echo $gofile
echo "Linting $gopackage"
golangci-lint run --disable=errcheck --timeout=10m $gopackage
done