-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgok.sh
executable file
·51 lines (41 loc) · 952 Bytes
/
gok.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
#!/bin/sh
o=$(mktemp tmp.XXXXXXXXXX)
fail() {
echo Failed
cat $o | grep -v deprecated
rm $o
exit 1
}
trap fail INT TERM
echo gofmt
gofmt -s -l $(find . -name '*.go') > $o 2>&1
test $(wc -l $o | awk '{ print $1 }') = "0" || fail
echo govet
go vet ./... > $o 2>&1 || fail
echo ineffassign
ineffassign . > $o 2>&1 || fail
echo misspell
misspell . > $o 2>&1 || fail
echo gocyclo
gocyclo -over 15 .\
| grep -v 'main Main text/main.go'\
| grep -v 'main Main ui/main.go'\
| grep -v 'ui execCmd ui/cmd.go'\
| grep -v 'edit runEditTest edit/edit_test.go'\
> $o 2>&1
e=$(mktemp tmp.XXXXXXXXXX)
touch $e
diff $o $e > /dev/null || { rm $e; fail; }
rm $e
echo go test
go test -test.timeout=60s ./... > $o 2>&1 || fail
echo golint
golint ./... \
> $o 2>&1
# Silly: diff the grepped golint output with empty.
# If it's non-empty, error, otherwise succeed.
e=$(mktemp tmp.XXXXXXXXXX)
touch $e
diff $o $e > /dev/null || { rm $e; fail; }
rm $e
rm $o