Home  >  Article  >  Backend Development  >  How to Fix 'zsh: command not found: go' Error on macOS?

How to Fix 'zsh: command not found: go' Error on macOS?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-11-08 03:00:01735browse

How to Fix

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!

Statement:
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