I have installed go-lang on my MacBook M2 Pro to compile hugo from the source code.

  1. Download

Site: https://go.dev/dl

Current: https://go.dev/dl/go1.22.1.darwin-arm64.tar.gz

  1. Install
cd Downloads
curl -OJL https://go.dev/dl/go1.22.1.darwin-arm64.tar.gz
tar xf go1.22.1.darwin-amd64.tar.gz
sudo mv go /usr/local
echo 'export PATH=/usr/local/go/bin:$PATH' >> ~/.zshrc
source ~/.zshrc
  1. Configure Local Folders
  • GOPATH: The folder to manage packages.
  • GOBIN: The folder to locate the package binary.
mkdir ~/.local/go
echo 'export GOPATH=~/.local/go' >> ~/.zshrc
echo 'export GOBIN=~/.local/bin' >> ~/.zshrc
source ~/.zshrc