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

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

Barbara Streisand
Barbara StreisandOriginal
2024-11-07 09:10:02192browse

Why isn't

Diagnosing "Go install not working with zsh" Issue

When attempting to install "go" using zsh, some users may encounter the error "zsh: command not found: go." This issue typically arises due to an incorrect or incomplete configuration. Let's delve deeper into the problem and its solution.

The provided configuration includes the following files:

  • "~/.bash_profile": This file adds "/usr/local/go/bin" to the $PATH environment variable.
  • "~/.zshrc": This file also adds "/usr/local/go/bin" to the $PATH environment variable.

However, if "go" was installed through the macOS package installer rather than Homebrew, the following modifications are necessary:

  • Set GOPATH to $HOME/go.
  • Set GOROOT to /usr/local/go.
  • Set GOBIN to $GOPATH/bin.
  • Add both $GOPATH and $GOROOT/bin to the $PATH environment variable.

The updated "~/.zshrc" file should look like this:

export GOPATH=$HOME/go
export GOROOT=/usr/local/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOPATH
export PATH=$PATH:$GOROOT/bin

After making these changes, the "go install" command should work as expected in zsh.

The above is the detailed content of Why isn't "go install" working with zsh?. 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