Home > Backend Development > Golang > Why Doesn't My Mac Recognize the 'go' Command After Go Installation?

Why Doesn't My Mac Recognize the 'go' Command After Go Installation?

Barbara Streisand
Release: 2024-12-10 15:09:15
Original
161 people have browsed it

Why Doesn't My Mac Recognize the 'go' Command After Go Installation?

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
Copy after login

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
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template