2014-04-02 16:53

无法在Mac OS X Mavericks中安装Go 1.2.1


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?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • duanlijia5864 duanlijia5864 7年前

    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

    点赞 评论 复制链接分享
  • dongpenggan6812 dongpenggan6812 4年前

    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.

    点赞 评论 复制链接分享
  • duanchao5258 duanchao5258 6年前

    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
    点赞 评论 复制链接分享