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

Mary-Kate Olsen
Release: 2024-11-07 01:54:03
Original
956 people have browsed it

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

.zshrc:

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

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

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!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!