duangutian1426 2012-10-11 15:21
浏览 89
已采纳

与brew一起安装go,并运行getour

I was following the http://tour.golang.org/ untill I got to the third step about that tells you that you can install the gotour on your system. After that I've installed the go language with brew by:

brew install hg
brew install go

Then I downloaded the gotour by:

go get code.google.com/p/go-tour/gotour

When I tried to launch the gotour it didnt recognise the command:

$ gotour
-bash: gotour: command not found

and

$ go gotour

and

$ ./gotour

So I tried to see the go path and it was empty,

echo $GOPATH

so I defined the GOPATH:

GOPATH=/usr/local/Cellar/go/1.0.2/src/pkg/code.google.com/p/
export GOPATH

Now I can run the gotour by runing

./gotour

But I'm insecure about my go enviroment.. wasn't I suposed to be able to run gotour by

go run gotour

or just by typing (like is described on this website http://www.moncefbelyamani.com/how-to-install-the-go-tour-on-your-mac/):

gotour

I would like to know if i'm doing things the right way since I'm new to the go programing language.

  • 写回答

6条回答 默认 最新

  • dongtong0796 2014-12-30 17:36
    关注

    Installing go 1.4 with homebrew on OSX:

    1) Create Directories

    mkdir $HOME/Go
    mkdir -p $HOME/Go/src/github.com/user
    

    2) Setup your paths

    export GOPATH=$HOME/Go
    export GOROOT=/usr/local/opt/go/libexec
    export PATH=$PATH:$GOPATH/bin
    export PATH=$PATH:$GOROOT/bin
    

    3) Install Go

    brew install go
    

    4) "go get" the basics

    go get golang.org/x/tools/cmd/godoc
    

    5) Start here: https://golang.org/doc/code.html at "your first program"

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程