-
Notifications
You must be signed in to change notification settings - Fork 185
Expand file tree
/
Copy pathinstall-vendored-go
More file actions
executable file
·70 lines (61 loc) · 1.7 KB
/
install-vendored-go
File metadata and controls
executable file
·70 lines (61 loc) · 1.7 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
63
64
65
66
67
68
69
70
#!/bin/sh
# The checksums below must correspond to the downloads for this version.
# The checksums can be found on https://go.dev/dl
GO_VERSION=go1.21.3
case "$(uname -s):$(uname -m)" in
Linux:x86_64)
GO_PKG=${GO_VERSION}.linux-amd64.tar.gz
GO_PKG_SHA=1241381b2843fae5a9707eec1f8fb2ef94d827990582c7c7c32f5bdfbfd420c8
;;
Darwin:x86_64)
GO_PKG=${GO_VERSION}.darwin-amd64.tar.gz
GO_PKG_SHA=27014fc69e301d7588a169ca239b3cc609f0aa1abf38528bf0d20d3b259211eb
;;
Darwin:arm64)
GO_PKG=${GO_VERSION}.darwin-arm64.tar.gz
GO_PKG_SHA=65302a7a9f7a4834932b3a7a14cb8be51beddda757b567a2f9e0cbd0d7b5a6ab
;;
*)
echo 1>&2 "I don't know how to install Go on your platform."
echo 1>&2 "Please install $GO_VERSION or later and add it to your PATH."
exit 1
;;
esac
archivesum() {
shasum -a256 "$ARCHIVE"
}
archiveok() {
test -f "$ARCHIVE" && archivesum | grep -q $GO_PKG_SHA
}
if go version 2>/dev/null | grep -q $GO_VERSION; then
go version
exit 0
fi
ROOTDIR="$( cd "$( dirname "$0" )/.." && pwd )"
VENDORDIR="$ROOTDIR/vendor"
DOWNLOAD_URL=https://go.dev/dl/$GO_PKG
ARCHIVE="$VENDORDIR/$GO_PKG"
INSTALLDIR="$VENDORDIR/$GO_VERSION"
export GOROOT="$INSTALLDIR/go"
INSTALLEDGO="$GOROOT/bin/go"
if [ -x $INSTALLEDGO ]; then
"$INSTALLEDGO" version
exit 0
fi
if ! archiveok; then
echo "Downloading $DOWNLOAD_URL"
mkdir -p "$VENDORDIR"
if ! curl -L -o "$ARCHIVE" $DOWNLOAD_URL; then
rm -f "$ARCHIVE"
echo 1>&2 "download failed"
fi
if ! archiveok; then
archivesum 1>&2
echo 1>&2 "expected checksum $GO_PKG_SHA"
exit 1
fi
fi
rm -rf "$INSTALLDIR"
mkdir -p "$INSTALLDIR"
tar xf "$ARCHIVE" -C "$INSTALLDIR"
"$INSTALLEDGO" version