forked from cubefs/cubefs-blobstore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode_check.sh
executable file
·32 lines (28 loc) · 1008 Bytes
/
code_check.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env bash
set -o errexit
set -o pipefail
source ./env.sh
#gofmt check
echo "gofmt check"
if [[ "${GOFMT_AND_MODIFY}" != "" ]];then
echo "Will use this command to format your local code: [find . -name "*.go" | grep -v "/vendor/" | xargs gofmt -s -w]"
find . -name "*.go" | grep -v "/vendor/" | xargs gofmt -s -w
else
echo "Will use this command to check your local code gofmt: [find . -name "*.go" | grep -v "/vendor/" | xargs gofmt -s -d]"
diff=`find . -name "*.go" | grep -v "/vendor/" | xargs gofmt -s -d`
if [[ -n "${diff}" ]]; then
echo "Gofmt check failed since of:"
echo "${diff}"
echo "Please run this command to fix: [find . -name "*.go" | grep -v "/vendor/" | xargs gofmt -s -w]"
exit 1
fi
fi
# go vet check
echo
echo "go vet check"
echo "Will use this command to check your local code: [go vet -tags="dev embed" ./...]"
go vet -tags="dev embed" `go list ./...`
if [[ $? -ne 0 ]];then
echo "go vet failed. exit"
exit 1
fi