How to Fix "Command Not Found: Go" After Installing Go on Mac
Upon installing Go, you may encounter an "zsh: command not found: go" error when attempting to run the 'go version' command. Follow these steps to resolve this issue:
Add the Path to Your ~/.zshrc File
Unlike bash, zsh requires you to add the path to your ~/.zshrc file. Open the file and add the following lines:
export PATH=$PATH:/usr/local/go/bin export PATH=$PATH:$GOPATH/bin
Replace "/usr/local/go" with the installation directory of Go on your system.
Source the ~/.zshrc File
Source your ~/.zshrc file to make the changes take effect:
. ~/.zshrc
Ensure that the path to the Go executable is added to both lines in the ~/.zshrc file. This will ensure that the 'go' command is recognized in your current zsh session.
After completing these steps, you should be able to run 'go version' and view the installed version of Go without encountering the "command not found" error.
The above is the detailed content of Why Doesn't My Mac Recognize the 'go' Command After Go Installation?. For more information, please follow other related articles on the PHP Chinese website!