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

Mary-Kate Olsen
Release: 2024-11-08 03:00:01
Original
725 people have browsed it

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
Copy after login

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!

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