Skip to content

Instantly share code, notes, and snippets.

@suzujun
Created November 8, 2019 10:50
Show Gist options
  • Save suzujun/02ab6666cec01ddfd3f63025d44814b3 to your computer and use it in GitHub Desktop.
Save suzujun/02ab6666cec01ddfd3f63025d44814b3 to your computer and use it in GitHub Desktop.
#!/bin/bash
golangci_lint() {
# $1: パス
# $2: サブパスも展開するか
DIR=$1
if [ -n "$2" ]; then
DIR=./$1/...
fi
echo -e "\n$DIR"
time $(golangci-lint run --issues-exit-code=0 --out-format=line-number $DIR >> golangci-lint.log)
}
golangci_lint_subpaths() {
# $1: 実行パス
DIRS=`find $1 -mindepth 1 -maxdepth 1 -type d`
for DIR in $DIRS; do
golangci_lint $DIR "yes"
done
}
rm -f golangci-lint.log
if [ "$1" = "diff" ]; then
echo "Execute for differences from master."
DIRS=`git diff master --name-only | grep -e "\.go$" | xargs -I% dirname % | uniq`
for DIR in $DIRS; do
golangci_lint $DIR
done
else
golangci_lint "cmd" true
golangci_lint_subpaths "pkg"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment