-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgo.sh
executable file
·78 lines (68 loc) · 1.63 KB
/
go.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
#!/usr/bin/env bash
GO_VERSION="1.14"
WORKING_DIRECTORY="/home/dev/.update/"
die() {
echo "$*" >&2
exit 444
}
clear_screen() {
clear
printf "\e[3J"
}
do_you_confirm() {
while :
do
echo ""
echo ""
echo "Installing Update System..."
sleep 1
echo ""
echo -e "Update system needs go environment."
echo ""
echo ""
echo -en "$1 Do you confirm? [y/n] "
read answer
echo ""
case "$answer" in
[yY] ) echo -e "Installation was started.\nPlease do not cancel the operation.\nOtherwise your system can be broke." && break ;;
[nN] ) die "Okay. Update service is cancelled." && break ;;
* ) clear_screen && echo "(!) Please use only Y or N" ;;
esac
done
}
push_enter() {
echo ""
echo -e "Installation was completed."
echo -e $1
echo ""
echo -e "[ Push enter to continue ] "
read answer
}
install_go() {
# Installs GVM if it is not.
if [[ ! -s "/home/dev/.gvm/" ]]; then
do_you_confirm "Gvm will be installed."
zsh < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer) >/dev/null 2>&1
source /home/dev/.gvm/scripts/gvm
push_enter "`gvm version`"
clear_screen
fi
source /home/dev/.gvm/scripts/gvm
# Installs go if it is not.
if [[ ! -s "/home/dev/.gvm/gos/go${GO_VERSION}/bin/go" ]]; then
do_you_confirm "Go ${GO_VERSION} will be installed."
gvm install go${GO_VERSION} -B >/dev/null 2>&1
gvm use go${GO_VERSION} --default >/dev/null 2>&1
push_enter "`go version`"
clear_screen
fi
}
run_go() {
go run main.go
}
main() {
cd ${WORKING_DIRECTORY}
install_go
run_go
}
main