Created
January 9, 2026 01:08
-
-
Save plattrap/a0e043677f5824dffcda4f0c554e6fb6 to your computer and use it in GitHub Desktop.
golang install and update
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/bash -x | |
| cd /tmp | |
| GO_ARCH=$(dpkg --print-architecture) | |
| GO_TARBALL=$(curl -sL -k https://go.dev/dl/ | grep -oP "go[0-9]+\.[0-9]+\.[0-9]+\.linux-${GO_ARCH}\.tar\.gz" | head -1) | |
| [ -z "$GO_TARBALL" ] && echo "Failed to detect Go version" && exit 1 | |
| [ -f "$GO_TARBALL" ] && echo "Already installed?? $GO_TARBALL" && exit 1 | |
| rm -f /tmp/go*.linux-${GO_ARCH}.tar.gz | |
| curl -OL -k "https://go.dev/dl/$GO_TARBALL" | |
| sudo find /usr/local/bin -lname '/usr/local/go/*' -delete | |
| sudo rm -rf /usr/local/go | |
| sudo tar -C /usr/local -xzf go*.linux-${GO_ARCH}.tar.gz | |
| for i in /usr/local/go/bin/*; do | |
| echo Linking: $i | |
| sudo ln -s --force $i /usr/local/bin/$(basename "$i") | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment