-
Notifications
You must be signed in to change notification settings - Fork 6
/
test.sh
78 lines (67 loc) · 1.04 KB
/
test.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/sh
set -e
RUN=$1
FLAGS=$2
set +ex
check_errcheck() {
errcheck ${FLAGS} ./...
}
check_fmt() {
gofmt -l .
}
check_imports() {
goimports -l .
}
check_lint() {
golint -set_exit_status ./...
}
check_sec() {
which gosec || go install -v github.com/securego/gosec/v2/cmd/gosec
gosec -out result.txt ${FLAGS} ./...
}
check_shadow() {
which shadow || go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow
go vet -vettool=`which shadow` ${FLAGS} ./...
}
check_staticcheck() {
which staticcheck || go install -v honnef.co/go/tools/cmd/staticcheck
staticcheck ${FLAGS} ./...
}
check_vet() {
go vet ${FLAGS} ./...
}
case ${RUN} in
"errcheck" )
check_errcheck
;;
"fmt" )
check_fmt
;;
"imports" )
check_imports
;;
"lint" )
check_lint
;;
"sec" )
check_sec
;;
"shadow" )
check_shadow
;;
"staticcheck" )
check_staticcheck
;;
"vet" )
check_vet
;;
* )
check_imports
check_fmt
check_lint
check_sec
check_shadow
check_errcheck
check_staticcheck
check_vet
esac