在Mac OS X Mavericks上安装Go 1.2.1失败。

huangapple go评论85阅读模式
英文:

Fail to install Go 1.2.1 in Mac OS X Mavericks

问题

我按照链接下载了Go 1.2.1,并尝试在Mavericks OSX上安装。在使用二进制包安装后,我进入路径/usr/local/go并找到了所有的可执行文件。然而,当我尝试运行

go version

时,返回的是

$ command not found: go

我不确定我做错了什么,但是我找不到任何相关资源。我还尝试按照这个教程(链接),但仍然失败。有什么帮助吗?

英文:

I followed the link to download Go 1.2.1 and tried to install in Mavericks OSX. After installing with the binary package, I cd into the path /usr/local/go and found all the executables. However when I try to run

go version

it returns

$ command not found: go

I am not sure what I did wrong but I can't find any resource to it. I also tried to follow this tutorial (link) but still failed. Any help?

答案1

得分: 10

如果二进制文件存在,则该目录不能在您的$PATH变量中。根据您提供的教程,请确保以下两行代码在您的shell配置文件中:

export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
英文:

If the binaries exist then the directory must not be in your $PATH variable. Per the tutorial you linked, make sure that the following two lines are in your shell profile:

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

答案2

得分: 6

默认情况下,Go语言安装在/usr/local/go/bin目录下。所以我通过在bash_profile文件中添加以下行来解决问题:

  • 编辑 ~/.bash_profile 文件(例如使用 nano ~/.bash_profile
  • 添加 export PATH=$PATH:/usr/local/go/bin
  • 保存文件,关闭并重新打开终端

然后应该可以正常工作:

$ go version
go version go1.4.2 darwin/amd64
英文:

By default go is installed in /usr/local/go/bin. So I fixed the issue by adding this line in bash_profile:

  • Edit ~/.bash_profile (for example with nano ~/.bash_profile)
  • add export PATH=$PATH:/usr/local/go/bin
  • save the file, close and open the terminal

and it should work:

$ go version
go version go1.4.2 darwin/amd64

答案3

得分: 0

在Mac上,下载存档并运行后,默认情况下,Go会安装在/usr/local/go目录下。接下来,你只需要在.profile文件中添加export PATH=$PATH:/usr/local/go/bin即可。如果遇到$ command not found: go之类的错误,只需重新启动终端。

据我所知,只有在根据官方安装说明安装到非/usr/local/go目录时,才会提到以下内容:

export GOROOT=$HOME/go1.X
export PATH=$PATH:$GOROOT/bin
英文:

On a Mac, after downloading the archive and running it, Go is by default installed at /usr/local/go. The next thing you do is to simply have export PATH=$PATH:/usr/local/go/bin in your .profile. If run into something like $ command not found: go, just restart your terminal.

As far as I'm concerned the only mention of

export GOROOT=$HOME/go1.X
export PATH=$PATH:$GOROOT/bin

is when you're installing a different location other than /usr/local/go according to the official installation instructions.

huangapple
  • 本文由 发表于 2014年4月3日 00:53:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/22818043.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定