-
Notifications
You must be signed in to change notification settings - Fork 388
Expand file tree
/
Copy pathinstall_go.sh
More file actions
executable file
·54 lines (42 loc) · 1.27 KB
/
install_go.sh
File metadata and controls
executable file
·54 lines (42 loc) · 1.27 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
#!/bin/bash
set -e
set -u
set -o pipefail
function main() {
if [[ "${CF_STACK:-}" != "cflinuxfs3" && "${CF_STACK:-}" != "cflinuxfs4" ]]; 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.6"
expected_sha="0ed64e3b9cb9b1c2ec57880dae2427b0ee2676f2ae2fb53c2e1bb838c500f9fb"
dir="/tmp/go${version}"
mkdir -p "${dir}"
if [[ ! -f "${dir}/bin/go" ]]; then
local url
url="https://buildpacks.cloudfoundry.org/dependencies/go/go_${version}_linux_x64_${CF_STACK}_${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 "${@:-}"