Configuring go install for ZSH on macOS
Encountering the "zsh: command not found: go" error while running go env indicates an issue with the configuration of your ZSH environment. The culprit lies in the configuration files: .bash_profile and .zshrc.
For macOS, if Go was installed using the package installer instead of Homebrew, the correct configuration in .zshrc for ZSH should be:
export GOPATH=$HOME/go export GOROOT=/usr/local/go export GOBIN=$GOPATH/bin export PATH=$PATH:$GOPATH export PATH=$PATH:$GOROOT/bin
This sets the GOPATH to your workspace directory (~/go), the GOROOT to the installed Go directory (/usr/local/go), the GOBIN to the bin directory within your workspace, and updates the PATH to include the Go installation and workspace directories.
The above is the detailed content of How to Fix 'zsh: command not found: go' Error on macOS?. For more information, please follow other related articles on the PHP Chinese website!