-
Notifications
You must be signed in to change notification settings - Fork 286
Expand file tree
/
Copy pathinstall_go.sh
More file actions
executable file
·55 lines (43 loc) · 1.34 KB
/
install_go.sh
File metadata and controls
executable file
·55 lines (43 loc) · 1.34 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
#!/bin/bash
set -e
set -u
set -o pipefail
function main() {
if [[ "${CF_STACK:-}" != "cflinuxfs4" && "${CF_STACK:-}" != "cflinuxfs5" ]]; then
echo " **ERROR** Unsupported stack"
echo " See https://docs.cloudfoundry.org/devguide/deploy-apps/stacks.html for more info"
exit 1
fi
local version expected_sha dir
version="1.25.7"
expected_sha="12a6e116cffdcd071988cf3c30216a3f08f54d2cfbb45fff67e375823fd0c3b9"
dir="/tmp/go${version}"
mkdir -p "${dir}"
if [[ ! -f "${dir}/bin/go" ]]; then
local url
# Use cflinuxfs4 binary for all stacks (compatible with cflinuxfs5)
url="https://buildpacks.cloudfoundry.org/dependencies/go/go_${version}_linux_x64_cflinuxfs4_${expected_sha:0:8}.tgz"
echo "-----> Download go ${version}"
curl "${url}" \
--silent \
--location \
--retry 15 \
--retry-delay 2 \
--output "/tmp/go.tgz"
local sha
sha="$(shasum -a 256 /tmp/go.tgz | cut -d ' ' -f 1)"
if [[ "${sha}" != "${expected_sha}" ]]; then
echo " **ERROR** SHA256 mismatch: got ${sha}, expected ${expected_sha}"
exit 1
fi
tar xzf "/tmp/go.tgz" -C "${dir}"
rm "/tmp/go.tgz"
fi
if [[ ! -f "${dir}/bin/go" ]]; then
echo " **ERROR** Could not download go"
exit 1
fi
GoInstallDir="${dir}"
export GoInstallDir
}
main "${@:-}"