generated from billowdev/exclusive-go-hexa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
40 lines (35 loc) · 824 Bytes
/
build.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
#!/bin/bash
# Set Swagger output directory
SWAGGER_OUTPUT="docs"
# Function to generate Swagger docs
generate_swagger_docs() {
echo "Generating Swagger docs..."
swag fmt
# https://github.com/swaggo/swag/issues/817
swag init --parseDependency -g cmd/main.go --output $SWAGGER_OUTPUT
}
# Function to run the application
run_app() {
echo "Running the application..."
go run cmd/main.go
}
# Main function to handle swag and run targets
main() {
case "$1" in
swag)
generate_swagger_docs
;;
run)
run_app
;;
app)
generate_swagger_docs
run_app
;;
*)
echo "Usage: $0 {swag|run|app}"
exit 1
esac
}
# Call the main function with the first argument
main "$1"