-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun.sh
executable file
·142 lines (140 loc) · 3.96 KB
/
run.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
main_question(){
echo "============================================\n"
echo "Please tell me what you want:"
echo "1. Set Up Environment (.env)"
echo "2. Do Unit Test"
echo "3. Update Swagger Documentation"
echo "4. Run Go Starter\n"
echo "0. Exit\n\n"
echo "Your Answer:"
}
bye_statement(){
echo
echo "See you again!"
}
echo "============================================"
echo "Hi, `whoami`\n. Welcome to Go Starter Configuration"
main_question
while :
do
read INPUT_STRING
case $INPUT_STRING in
1)
echo
FILE=.env
if [ ! -f "$FILE" ]; then
cp .env.example .env
echo "============================================"
echo "= Environment file (.env) has been created ="
fi
echo "============================================"
echo "Open Environment in: "
echo "1. Default IDE"
echo "2. Visual Code"
echo "3. Folder\n"
echo "0. Back\n"
echo "Your Answer:"
while :
do
read IDE
case $IDE in
1)
echo "\nOpen Environment in Default IDE ..."
open .env
bye_statement
exit
;;
2)
echo "\nOpen Environment in Visual Code ..."
code .env
bye_statement
exit
;;
3)
echo "\nOpen Environment in Folder ..."
open .
bye_statement
exit
;;
0)
echo
main_question
break
;;
esac
done
;;
2)
echo "Please wait ..."
echo "============================================"
echo "Run for: "
echo "1. Default Unit Test"
echo "2. Coverage Unit Test"
echo "0. Back\n"
echo "Your Answer:"
while :
do
read IDE
case $IDE in
1)
echo "Default Unit Test"
go test ./... -p=1
rm -rf test.db
rm -rf testsy.db
bye_statement
exit
;;
2)
echo "Coverage Unit Test"
go test -p=1 -coverprofile cp.out -v ./... && go tool cover -html=cp.out
rm -rf test.db
rm -rf testsy.db
bye_statement
exit
;;
0)
echo
main_question
break
;;
esac
done
;;
3)
{ # try 1 // Running Swag
echo
swag init --parseDependency --parseInternal
} || { # catch 1
{ # try 2 // Running Swag
echo "============================================"
echo "swag not found in app directory ..."
echo "trying to find swag in GOPATH root folder ..."
$HOME/go/bin/swag init --parseDependency --parseInternal
} || { # catch 2 and else
echo "============================================"
echo "Please provide your golang location:"
echo "(e.g. /Users/kuncoro.barot/go)"
read MY_NAME
echo "Please wait ..."
$MY_NAME/bin/swag init --parseDependency --parseInternal
}
}
break
;;
4)
echo "Please wait ..."
go run main.go
break
;;
0)
break
;;
*)
echo "============================================"
echo "Sorry, I don't understand"
echo "Please answer with correct key or type 0 for close the configuration"
main_question
;;
esac
done
bye_statement