Last active
October 29, 2024 14:50
-
-
Save gsrai/09bfc7db6548aecfbeacdcd89dcd0720 to your computer and use it in GitHub Desktop.
Install Go on M1/M2/M3 mac (apple silicon)
This file contains 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/env bash | |
# find filename on https://go.dev/dl/ | |
GO_FILE_NAME="go1.19.3.darwin-arm64.tar.gz" | |
# usage: | |
# chmod u+x install_go.sh | |
# sudo ./install_go.sh | |
mkdir /tmp/downloads | |
sudo wget https://golang.org/dl/$GO_FILE_NAME -P /tmp/downloads | |
sudo tar -C /usr/local -xzf /tmp/downloads/$GO_FILE_NAME | |
echo 'export GOROOT="/usr/local/go"' >> $HOME/.zshrc | |
echo 'export GOPATH="$HOME/dev/go"' >> $HOME/.zshrc | |
echo 'export PATH="$GOPATH/bin:$GOROOT/bin:$PATH"' >> $HOME/.zshrc |
This file contains 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/env bash | |
# Find filename on https://go.dev/dl/ | |
GO_FILE_NAME="go1.21.0.darwin-arm64.tar.gz" # M1 Apple Silicon | |
# Usage: | |
# chmod u+x update_go.sh | |
# sudo ./update_go.sh | |
# | |
# If something goes wrong, just restore the backup: | |
# mv /usr/local/_go_old /usr/local/go | |
# | |
# If everything is ok, then you can remove the backup: | |
# sudo rm -rf /usr/local/_go_old | |
sudo mv /usr/local/go /usr/local/_go_old | |
mkdir /tmp/downloads | |
sudo wget https://golang.org/dl/$GO_FILE_NAME -P /tmp/downloads | |
sudo tar -C /usr/local -xzf /tmp/downloads/$GO_FILE_NAME | |
go version | |
I was having troubles while installing golang via brew (probably due to wrong path configs)
Everything went smoothly with this script, thanks
(M3 pro)
thanks man this worked !!!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks worked well on Apple M1