-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgo-install.sh
More file actions
executable file
·62 lines (50 loc) · 1.38 KB
/
Copy pathgo-install.sh
File metadata and controls
executable file
·62 lines (50 loc) · 1.38 KB
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
#!/bin/bash
#
# Copyright (C) 2024-2026 Joelle Maslak
# All Rights Reserved - See License
#
set -euo pipefail
GOLANGVER=1.26.0
BASEURL="https://go.dev/dl"
doit() {
if [ -x /usr/local/go/bin/go ] ; then
ver=$(/usr/local/go/bin/go version | awk '{print $3}')
if [ "$ver" == "go$GOLANGVER" ] ; then
echo "/usr/local/go/bin/go is up-to-date"
return
else
echo "/usr/local/go/bin/go is out-of-date ($ver), updating..."
fi
fi
macharch=$(uname -om)
case "$macharch" in
"Darwin arm64")
goarch="darwin-arm64"
;;
"x86_64 GNU/Linux")
goarch="linux-amd64"
;;
*)
echo "Cannot determine go arch for $macharch" >&2
exit 1
;;
esac
echo "Go architecture: $goarch"
url="$BASEURL/go$GOLANGVER.$goarch.tar.gz"
tmpfile=$(mktemp /tmp/go-download.tgz.XXXXXX)
curl -L "$url" >"$tmpfile"
echo "Downloaded!"
echo ""
echo "You may be asked to provide your password to install golang:"
if [ -d /usr/local/go ] ; then
sudo rm -rf /usr/local/go
fi
sudo tar -xvzf "$tmpfile" --cd /usr/local
rm "$tmpfile"
# shellcheck disable=SC2155
export GOROOT="/usr/local/go"
# shellcheck disable=SC2155
export PATH="$HOME/go/bin:$(pwd)/go/bin:$PATH"
./go-modules.sh
}
doit "$@"