Home > Article > Backend Development > Why isn't 'go install' working with zsh on macOS?
Troubleshoot "Go install not working with zsh" Error
When attempting to install Go with zsh, macOS users may encounter an error despite seemingly correct configuration.
Issue Details:
The user created a ~/go workspace directory and set the following in their configuration files:
.bash_profile:
export PATH=$PATH:/usr/local/go/bin
.zshrc:
export PATH=$PATH:/usr/local/go/bin
However, running go env returns "zsh: command not found: go".
Solution:
If Go was installed on macOS through the macOS package installer rather than Homebrew, the configuration requires additional environment variables in ~/.zshrc:
export GOPATH=$HOME/go export GOROOT=/usr/local/go export GOBIN=$GOPATH/bin export PATH=$PATH:$GOPATH export PATH=$PATH:$GOROOT/bin
These variables specify the GOPATH, GOROOT, GOBIN, and PATH for the Go environment, directing it to the correct locations for the installed Go binaries.
The above is the detailed content of Why isn't 'go install' working with zsh on macOS?. For more information, please follow other related articles on the PHP Chinese website!