Home  >  Article  >  Backend Development  >  Why isn't "go install" working with zsh on macOS?

Why isn't "go install" working with zsh on macOS?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-11-07 01:54:03941browse

Why isn't

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!

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