找不到命令go-安装Go后在Mac上 [英] Command not found go — on Mac after installing Go

查看:661
本文介绍了找不到命令go-安装Go后在Mac上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用golang,但是我在运行go命令时遇到了麻烦.我安装了go1.5.2 darwin/amd64,但是当我运行命令go version时,在终端zsh: command not found: go中出现错误.我在bash配置文件中添加了路径export PATH=$PATH:/usr/local/go/bin,但是仍然出现错误(我重新启动了终端btw).我已卸载并重新安装,但是没有运气.有人可以帮我解决这个问题吗?我不确定安装中是否有错误,但下载成功.如果不进行锻炼,我可能必须下载旧版本的go.

I want to use golang, but I'm having trouble running the go command. I installed go1.5.2 darwin/amd64, but when I run the command go version, I get an error in the terminal zsh: command not found: go. I added the path export PATH=$PATH:/usr/local/go/bin to the bash profile, but I still get the error (I restarted the terminal btw). I uninstalled and reinstalled, but no luck. Can anybody help me troubleshoot this? I'm not sure if there was an error in the installation, but it downloaded ok. I may have to download an older version of go if this doesn't workout.

推荐答案

类似于上述评论中提到的 bjhaid :

Like bjhaid mentioned in the comments above:

之所以会这样,是因为您必须将PATH添加到~/.zshrc文件中.

This is happening because you must add your PATH to your ~/.zshrc file.

~/.zshrc中,应添加以下行:

export PATH=$PATH:/usr/local/go/bin

然后您应该为您的.zshrc文件提供来源:

you should then source you .zshrc file:

. ~/.zshrc

这篇关于找不到命令go-安装Go后在Mac上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆