我一直在遵循http://tour.golang.org/,直到我走到第三步,它告诉你你可以在你的系统上安装gotour。之后,我通过以下方式安装了带有brew的go语言:
brew install hg
brew install go然后,我通过以下方式下载了gotour:
go get code.google.com/p/go-tour/gotour当我试图启动gotour时,它不能识别命令:
$ gotour
-bash: gotour: command not found和
$ go gotour和
$ ./gotour所以我试着去看go路径,它是空的,
echo $GOPATH所以我定义了GOPATH:
GOPATH=/usr/local/Cellar/go/1.0.2/src/pkg/code.google.com/p/
export GOPATH现在我可以通过运行以下命令来运行gotour
./gotour但是我对我的围棋环境不太放心..我不是应该能跑过去吗?
go run gotour或者只需输入(如本网站http://www.moncefbelyamani.com/how-to-install-the-go-tour-on-your-mac/中所述):
gotour我想知道我做事情的方式是否正确,因为我是go编程语言的新手。
发布于 2014-12-31 01:36:27
在OSX上安装带有homebrew的go 1.4:
1)创建目录
mkdir $HOME/Go
mkdir -p $HOME/Go/src/github.com/user2)设置你的路径
export GOPATH=$HOME/Go
export GOROOT=/usr/local/opt/go/libexec
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin3)安装Go
brew install go4)“获取”基础知识
go get golang.org/x/tools/cmd/godoc5)从这里开始:“你的第一个程序”中的https://golang.org/doc/code.html
发布于 2016-10-19 19:08:26
在上面的混合答案之后,这是我在使用自制软件的OSX 10.12 (Sierra)和Go v1.7.1上有效的方法:
我在我的.zshrc或.bashrc中添加了科什答案中的这段话
# Go development
export GOPATH="${HOME}/.go"
export GOROOT="$(brew --prefix golang)/libexec"
export PATH="$PATH:${GOPATH}/bin:${GOROOT}/bin"
test -d "${GOPATH}" || mkdir "${GOPATH}"
test -d "${GOPATH}/src/github.com" || mkdir -p "${GOPATH}/src/github.com"然后在新的终端窗口/选项卡中:
$ brew install go
==> Downloading https://homebrew.bintray.com/bottles/go-1.7.1.sierra.bottle.tar.gz
Already downloaded: /Users/nigel/Library/Caches/Homebrew/go-1.7.1.sierra.bottle.tar.gz
==> Pouring go-1.7.1.sierra.bottle.tar.gz
==> Caveats
As of go 1.2, a valid GOPATH is required to use the `go get` command:
https://golang.org/doc/code.html#GOPATH
You may wish to add the GOROOT-based install location to your PATH:
export PATH=$PATH:/usr/local/opt/go/libexec/bin
==> Summary
/usr/local/Cellar/go/1.7.1: 6,436 files, 250.6M
$ go get golang.org/x/tools/cmd/godoc
$ go get github.com/golang/lint/golint
$ go get golang.org/x/tour/gotour
$ gotour
2016/10/19 12:06:54 Serving content from /Users/nigel/.go/src/golang.org/x/tour
2016/10/19 12:06:54 A browser window should open. If not, please visit http://127.0.0.1:3999
2016/10/19 12:06:55 accepting connection from: 127.0.0.1:52958发布于 2012-10-12 23:20:28
我想我已经找到了解决方案,我应该输出:
export PATH=$PATH:/usr/local/Cellar/go/1.0.2/bin/而不是
GOPATH=/usr/local/Cellar/go/1.0.2/src/pkg/code.google.com/p/
export GOPATH因为那是'go get‘放置二进制文件的地方(我猜)。gotour正在工作:
$ gotour
2012/10/11 18:35:50 Serving content from /usr/local/Cellar/go/1.0.2/src/pkg/code.google.com/p/go-tour
2012/10/11 18:35:50 Open your web browser and visit http://127.0.0.1:3999/ 顺便说一下,我的答案是基于这篇文章。
他们谈论导出的http://code.google.com/p/go-tour/issues/detail?id=39:
/usr/local/Cellar/go/1.0.2/src/pkg/code.google.com/p/还有go:http://golang.org/doc/install的入门页面,他们说你必须在那里导出:
export PATH=$PATH:/usr/local/go/binhttps://stackoverflow.com/questions/12843063
复制相似问题