"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > How to Fix "zsh: command not found: go" Error on macOS?

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

Published on 2024-11-09
Browse:148

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

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.

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3