效果如下:
❯ echo $PATH
/opt/homebrew/opt/openjdk/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin
❯ go version
go version go1.20.5 darwin/arm64
❯ brew unlink go && brew unlink go@1.18 && brew link go@1.18 && go version
Unlinking /opt/homebrew/Cellar/go/1.20.5... 2 symlinks removed.
Unlinking /opt/homebrew/Cellar/go@1.18/1.18.10... 0 symlinks removed.
Linking /opt/homebrew/Cellar/go@1.18/1.18.10... 2 symlinks created.
If you need to have this software first in your PATH instead consider running:
echo 'export PATH="/opt/homebrew/opt/go@1.18/bin:$PATH"' >> ~/.zshrc
go version go1.18.10 da