Skip to content

Instantly share code, notes, and snippets.

@gsrai
Last active November 27, 2024 14:43
Show Gist options
  • Save gsrai/09bfc7db6548aecfbeacdcd89dcd0720 to your computer and use it in GitHub Desktop.
Save gsrai/09bfc7db6548aecfbeacdcd89dcd0720 to your computer and use it in GitHub Desktop.
Install Go on M1/M2/M3 mac (apple silicon)
#!/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
#!/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
@SashaDesigN
Copy link

Thanks worked well on Apple M1

@LeonardoFraliniU2Y
Copy link

I was having troubles while installing golang via brew (probably due to wrong path configs)
Everything went smoothly with this script, thanks

(M3 pro)

@navidRashik
Copy link

thanks man this worked !!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment