go工具:没有名为”tour”的工具。

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

go tool: no such tool "tour"

问题

我正在尝试使用Go语言,第一次接触。我正在按照这些文档(https://tour.golang.org/welcome/3)进行操作,并希望在本地运行Go教程,但我还没有弄清楚如何使其工作。

工具"tour"应该在哪里找到?
我使用的是OSX 10.11.3,并通过Homebrew安装了Go。
我的.zshrc文件中有以下Go条目:

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

I'm trying out Go for the first time. I was following these docs and wanted to run the go tour locally, but I haven't figured out how to get it to work.

Where is the tool "tour" supposed to be found?
I'm on OSX 10.11.3, and I installed Go via Homebrew
my Go entries in .zshrc

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

答案1

得分: 68

tour 在安装 Go 时不会默认安装。你需要使用 go get 命令来安装它:

go get golang.org/x/tour/gotour

文档:https://github.com/golang/tour/

英文:

tour is not installed by default with an installation of go. You need to go get it:

go get golang.org/x/tour/gotour

Docs: https://github.com/golang/tour/

答案2

得分: 11

我也遇到了一个问题。这是我的解决方案,在OSX上尝试一下:

gotour

使用版本为go1.8.1 darwin/amd64

英文:

I had a problem too. This's my solution, on OSX let try

gotour

With version <code>go1.8.1 darwin/amd64
</code>

答案3

得分: 6

这在使用go1.4版本时对我有效,但在使用go1.7版本时不行。如果你只是运行go tool,它会给你一个已知工具的列表。它们似乎已经从工具中移除了它。

$ gvm use go1.7
$ go tool
addr2line
api
asm
cgo
compile
cover
dist
doc
fix
link
nm
objdump
pack
pprof
trace
vet
yacc

$ gym use go1.4
$ go tool
6a
6c
6g
6l
addr2line
cgo
cover
dist
fix
nm
objdump
pack
pprof
tour      # &lt;--- 这里
vet
yacc
英文:

It works for me using go1.4, but not with go1.7. If you just run go tool, it gives you a list of known tools. They seem to have removed it from tools.

$ gvm use go1.7
$ go tool
addr2line
api
asm
cgo
compile
cover
dist
doc
fix
link
nm
objdump
pack
pprof
trace
vet
yacc

$ gym use go1.4
$ go tool
6a
6c
6g
6l
addr2line
cgo
cover
dist
fix
nm
objdump
pack
pprof
tour      # &lt;--- here
vet
yacc

答案4

得分: 4

首先,它不再是gotour。其次,目前,tour包位于golang.org/x/website/tour,而不是A Tour of Go Welcome Page中所说的那样。

所以,至少目前为止:

获取tour的正确方式是:

go get golang.org/x/website/tour

或者,

go install golang.org/x/website/tour@latest

之后,你可以在终端中运行以下命令:

$ tour
2021/06/22 17:46:48 Serving content from /home/user/go/pkg/mod/golang.org/x/website/tour@v0.0.0-20210616181959-e0d934b43647
2021/06/22 17:46:48 A browser window should open. If not, please visit http://127.0.0.1:3999
2021/06/22 17:46:52 accepting connection from: 127.0.0.1:33192

要找出它安装在哪里,你可以执行which tour命令:

$ which tour
/home/user/go/bin//tour

参考链接

英文:

Firstly, it is no longer gotour. And secondly, for the time being, the tour package is located at: golang.org/x/website/tour as opposed to what A Tour of Go Welcome Page says.

So, at least for now:

The correct way to get tour is:

go get golang.org/x/website/tour

Or,

go install golang.org/x/website/tour@latest

After which you can run the command in the terminal:

$ tour
2021/06/22 17:46:48 Serving content from /home/user/go/pkg/mod/golang.org/x/website/tour@v0.0.0-20210616181959-e0d934b43647
2021/06/22 17:46:48 A browser window should open. If not, please visit http://127.0.0.1:3999
2021/06/22 17:46:52 accepting connection from: 127.0.0.1:33192

To find out where it has been installed, you can do which tour:

$ which tour
/home/user/go/bin//tour

reference

答案5

得分: 3

由于Go包管理的变化和模块的引入,自原始问题以来,这一点已经发生了变化。因此,供将来参考(因为这是第一个谷歌搜索结果),如果您尚未配置GOPATH环境变量

go get golang.org/x/tour
$HOME/go/bin/tour

请注意,可执行文件的名称为"tour"而不是"gotour"。

来源(包含完整的解释和详细信息):https://stephencharlesweiss.com/getting-going-with-golang/

英文:

Because of changes in Go package management and introduction of modules, this has changed since the original question. Thus, for future reference (as this is the first Google result), if you have not configured GOPATH environment variable

go get golang.org/x/tour
$HOME/go/bin/tour

Note that the executable is called "tour" instead of "gotour".

Source (with full explanation of why and details): https://stephencharlesweiss.com/getting-going-with-golang/

答案6

得分: 2

我已经得到了:

> golang.org/x/tour/gotour已经迁移到golang.org/x/tour

所以,对我来说这样可以工作:
<pre>go get golang.org/x/tour</pre>

然后:
<pre>tour</pre>

英文:

I've got:
> golang.org/x/tour/gotour has moved to golang.org/x/tour

So, this works for me:
<pre>go get golang.org/x/tour</pre>

then:
<pre>tour</pre>

答案7

得分: 0

当你安装Go语言时,默认情况下不会安装tour。你需要执行go get golang.org/x/tour/gotour命令来下载gotour到你的工作目录。

如果你正确配置了PATH环境变量,那么在终端的任何位置输入gotour命令都会在浏览器中打开gotour,但如果PATH没有正确配置,可以使用以下命令:

$GOPATH/bin/gotour

这个命令可以在命令行的任何位置使用,并在默认浏览器中打开gotour

你可以参考以下链接了解如何在本地运行Go Tour:

http://whipperstacker.com/2015/09/27/how-to-run-the-go-tour-locally/

https://github.com/golang/tour/blob/master/README.md

英文:

When you install go, tour is not installed by default. You need to do a go get golang.org/x/tour/gotour. This downloads gotour in your workspace.

If you configured your PATH properly, gotour command from anywhere in the terminal will open up your browser, but if PATH is not configured properly, do a

   $GOPATH/bin/gotour 

This command can be used from anywhere in your command line and it opens tour in your default browser

http://whipperstacker.com/2015/09/27/how-to-run-the-go-tour-locally/

https://github.com/golang/tour/blob/master/README.md

答案8

得分: -1

一旦安装了gotour,它就像其他可执行文件一样存储在工作区的bin目录中。在bin目录内,使用./gotour来调用或启动gotour,在其他位置,需要在gotour之前加上可执行文件所在的路径。换句话说,当你不在bin目录内时,使用$GOPATH/bin/gotour来调用或启动gotour

英文:

Once gotour is installed, it’s executable like other executables are typically stored in the bin directory of your workspace. Inside the bin directory ./gotour will invoke or start gotour, elsewhere the gotour will need to be preceded by a path to where the executable is located. In other words $GOPATH/bin/gotour will invoke or start gotour when you are not inside the bin directory.

huangapple
  • 本文由 发表于 2016年1月22日 10:52:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/34938182.html
匿名

发表评论

匿名网友

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

确定