-
Notifications
You must be signed in to change notification settings - Fork 0
/
godo
executable file
·86 lines (70 loc) · 1.33 KB
/
godo
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
79
80
81
82
83
84
85
86
#!/bin/bash
clear
set -e
tabs -2
TEST_TIMEOUT="2s"
BUILD_FLAGS=""
#BUILD_FLAGS=-gcflags -m -ldflags "-s -w"
printUsage() {
println "Usage:"
println "\t" "./godo [help] " "\t\t" "# Print usage"
println "\t" "./godo docs " "\t\t" "# Fire up documentation server"
println "\t" "./godo clean " "\t\t" "# Clean Go caches"
println "\t" "./godo (test|commit)" "\t\t" "# fmt -> test -> vet"
}
println() {
for s in "$@"
do
printf "$s"
done
printf "\\n"
}
goDoc() {
doc_port=":3001"
println "Documentation..."
println
println "\t" "Libs - http://localhost${doc_port}/pkg/#thirdparty"
println
println "\t" "Go - http://localhost${doc_port}/pkg/#stdlib"
println
println "\t" "All - http://localhost${doc_port}/"
println
godoc -http=${doc_port}
}
goClean() {
println "Deep cleaning..."
go clean -cache -testcache
}
goFmt() {
println "Formatting..."
go fmt ./...
}
goTest() {
println "Testing..."
go test ./... -timeout $TEST_TIMEOUT
}
goVet() {
println "Vetting..."
go vet ./...
}
if [[ "$1" == "" || "$1" == "help" ]]; then
printUsage
exit 0
fi
if [[ "$1" == "docs" ]]; then
goDoc
exit 0
fi
if [[ "$1" == "clean" ]]; then
goClean
exit 0
fi
if [[ "$1" == "test" || "$1" == "commit" ]]; then
goFmt
goTest
goVet
exit 0
fi
println "I don't understand the option '$1'."
printUsage
exit 1