Home > Backend Development > Golang > Why Can't I Find the 'go' Command After Installing Go in zsh?

Why Can't I Find the 'go' Command After Installing Go in zsh?

Barbara Streisand
Release: 2024-11-25 13:02:11
Original
392 people have browsed it

Why Can't I Find the

Troubleshooting Go Installation Issues in zsh

Facing difficulties with installing Go using zsh? Let's troubleshoot your setup and identify the missing pieces.

You have created a workspace directory (~/go) and added the following line to your ~/.bash_profile and ~/.zshrc files:

export PATH=$PATH:/usr/local/go/bin
Copy after login

Despite these additions, when you run "go env" from your home directory, you receive the error "zsh: command not found: go." This suggests that your configuration is incorrect.

If you installed Go on macOS using the package installer rather than Homebrew, your GOBIN will reside in /usr/local/go and GOPATH in $HOME/go. To rectify this, adjust your ~/.zshrc file as follows:

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

By making these changes, you ensure that the correct directories are included in your PATH environment variable, allowing you to execute Go commands from any directory.

The above is the detailed content of Why Can't I Find the 'go' Command After Installing Go in zsh?. 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