-
Notifications
You must be signed in to change notification settings - Fork 1
/
install_go.sh
executable file
·89 lines (78 loc) · 1.91 KB
/
install_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
79
80
81
82
83
84
85
86
87
88
89
#!/bin/sh
#############################################################
# Set development environment on Linux/macOS/Cygwin quickly.
# Author: Maririn312 <khatanzorigb@gmail.com>
# URL: https://github.com/maririn312/dotfiles
#############################################################
# Go packages
packages=(
golang.org/x/tools/gopls
golang.org/x/tools/cmd/goimports
honnef.co/go/tools/cmd/staticcheck
github.com/zmb3/gogetdoc
github.com/go-delve/delve/cmd/dlv
github.com/aarzilli/gdlv
github.com/josharian/impl
github.com/cweill/gotests/...
github.com/fatih/gomodifytags
github.com/davidrjenni/reftools/cmd/fillstruct
github.com/google/gops
github.com/haya14busa/goplay/cmd/goplay
)
# Use colors, but only if connected to a terminal, and that terminal
# supports them.
if command -v tput >/dev/null 2>&1; then
ncolors=$(tput colors)
fi
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
YELLOW="$(tput setaf 3)"
BLUE="$(tput setaf 4)"
BOLD="$(tput bold)"
NORMAL="$(tput sgr0)"
else
RED=""
GREEN=""
YELLOW=""
BLUE=""
BOLD=""
NORMAL=""
fi
YES=0
NO=1
function promote_yn() {
eval ${2}=$NO
read -p "$1 [y/N]: " yn
case $yn in
[Yy]* ) eval ${2}=$YES;;
[Nn]*|'' ) eval ${2}=$NO;;
*) eval ${2}=$NO;;
esac
}
function check() {
if ! command -v go >/dev/null 2>&1; then
echo "${RED}Error: go is not installed${NORMAL}" >&2
exit 1
fi
}
function install() {
for p in ${packages[@]}; do
printf "${BLUE} ➜ Installing ${p}...${NORMAL}\n"
GO111MODULE=on go install ${p}@latest
done
}
function goclean() {
rm -rf $GOPATH/src/$1
rm -rf $GOPATH/pkg/mod/{$1}*
}
function clean() {
for p in ${packages[@]}; do
goclean ${p}
done
}
function main() {
check
install
}
main