Skip to content

Instantly share code, notes, and snippets.

@AndyIsHereBoi
Last active July 26, 2025 20:28
Show Gist options
  • Save AndyIsHereBoi/9e8097b4c4cb911f272e936d64e2c368 to your computer and use it in GitHub Desktop.
Save AndyIsHereBoi/9e8097b4c4cb911f272e936d64e2c368 to your computer and use it in GitHub Desktop.
Install go 1.24.1 on linux
#!/bin/bash
# Check if the script is running as root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root."
exit 1
fi
# Remove existing Go installation (if any)
rm -rf /usr/local/go
# Download Go 1.20.10
wget https://go.dev/dl/go1.24.1.linux-amd64.tar.gz
# Extract Go to /usr/local
tar -C /usr/local -xzf go1.24.1.linux-amd64.tar.gz
# Update PATH environment variable
export PATH="$PATH:/usr/local/go/bin"
# Update shell configuration file (adjust based on your shell)
case "$SHELL" in
/bin/bash)
echo "export PATH=\"$PATH\"" >> ~/.bashrc
;;
/bin/zsh)
echo "export PATH=\"$PATH\"" >> ~/.zshrc
;;
/usr/bin/fish)
echo "set -x PATH $PATH /usr/local/go/bin" >> ~/.config/fish/config.fish
;;
/bin/csh | /bin/tcsh)
echo "setenv PATH ($PATH:/usr/local/go/bin)" >> ~/.cshrc
;;
/bin/sh)
echo "export PATH=\"$PATH\"" >> ~/.bashrc
;;
*)
echo "Unsupported shell: $SHELL"
exit 1
;;
esac
echo "Go 1.24.1 installed successfully. Please source your shell's configuration file (e.g., source ~/.bashrc) or log out and log back in for the changes to take effect."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment