Skip to content

Commit

Permalink
install go via script
Browse files Browse the repository at this point in the history
  • Loading branch information
powersj committed Jun 2, 2022
1 parent e2d2cb9 commit 0f70b20
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ jobs:
- restore_cache:
key: go-mod-v1-{{ checksum "go.sum" }}
- check-changed-files-or-halt
- run: 'snap install go --classic'
- run: './scripts/installgo_linux.sh'
- run: 'make deps'
- run: 'make test-integration'
test-go-mac:
Expand Down
34 changes: 34 additions & 0 deletions scripts/installgo_linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh

set -eux

ARCH=$(uname -m)
GO_VERSION="1.18.3"
GO_ARCH="linux-amd64"
# from https://golang.org/dl
GO_VERSION_SHA="956f8507b302ab0bb747613695cdae10af99bbd39a90cae522b7c0302cc27245"

setup_go () {
echo "installing go"
curl -L https://golang.org/dl/go${GO_VERSION}.${GO_ARCH}.tar.gz --output go${GO_VERSION}.${GO_ARCH}.tar.gz
if ! echo "${GO_VERSION_SHA} go${GO_VERSION}.${GO_ARCH}.tar.gz" | shasum --algorithm 256 --check -; then
echo "Checksum failed" >&2
exit 1
fi

rm -rf /usr/local/go
tar -C /usr/local -xzf go${GO_VERSION}.${GO_ARCH}.tar.gz
sudo ln -sf /usr/local/go/bin/go /usr/local/bin/go
}

if command -v go >/dev/null 2>&1; then
echo "Go is already installed"
v=$(go version | { read -r _ _ v _; echo "${v#go}"; })
echo "$v is installed, required version is ${GO_VERSION}"
if [ "$v" != ${GO_VERSION} ]; then
setup_go
go version
fi
else
setup_go
fi

0 comments on commit 0f70b20

Please sign in to comment.