英文:
Starting the gotour
问题
我已经安装了go(并测试了它)。当我运行go env
时,我看到了这个:
$ go env
GOROOT=""/usr/lib/go""
GOBIN=""""
GOARCH="386""
GOCHAR="8""
GOOS="linux""
GOEXE=""""
GOHOSTARCH="386""
GOHOSTOS="linux""
GOTOOLDIR=""/usr/lib/go/pkg/tool/linux_386""
GOGCCFLAGS=""/g -O2 -fPIC -m32 -pthread""
CGO_ENABLED="1""
然而,当我运行go get code.google.com/p/go-tour/gotour
来开始本地游览(根据说明),似乎什么都没有发生(我没有输出,尽管运行需要几秒钟,这让我觉得一定发生了一些事情)。
说明中说要运行生成的gotour可执行文件,但我找不到它。有人知道我做错了什么吗?我开始觉得自己可能很笨,但我就是找不出运行go get
做了什么(它安装了什么?它成功了吗?)。
英文:
I've installed go (and tested it). When I run go env
I see this:
$ go env
GOROOT="/usr/lib/go"
GOBIN=""
GOARCH="386"
GOCHAR="8"
GOOS="linux"
GOEXE=""
GOHOSTARCH="386"
GOHOSTOS="linux"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_386"
GOGCCFLAGS="-g -O2 -fPIC -m32 -pthread"
CGO_ENABLED="1"
However, when I run go get code.google.com/p/go-tour/gotour
to get started with the tour locally (per the instructions), nothing seems to happen (I get no output, though it does take a couple of seconds to run, which makes me think something must have happened).
The instructions say to run the resultant gotour executable, but I can't find one. Anyone know what I'm doing wrong? I'm starting to feel like I must be pretty dumb, but I just can't figure out what running go get
did (did it install anything? did it succeed?).
答案1
得分: 8
你有查看过 /usr/lib/go/bin
吗?或者,如果你设置了 gopath $GOPATH/bin
。
默认情况下,go get
只在出现错误时才会打印信息。生成的可执行文件会被放置在 GOBIN、GOROOT bin 或 GOPATH bin 中。
英文:
Have you looked in /usr/lib/go/bin
? Or, if you set a gopath $GOPATH/bin
.
By default, go get
only prints if there was an error. The resultant executable is placed in the GOBIN, the GOROOT bin, or the GOPATH bin.
答案2
得分: 1
gotour
可执行文件应该已经由您的go安装提供。
当您在执行之前没有执行指示的go get
时运行gotour
,它应该会提供一个导入错误。
2012/07/28 09:10:18 找不到tour文件:导入“code.google.com/p/go-tour/”:找不到包
运行go get
将获取源代码 - 在这种情况下是从code.google.com/p/go-tour
- 并将其放置在您活动的go环境源文件夹中,对于您来说是GOROOT="/usr/lib/go"
(如果没有设置GOPATH
)。源代码将被放置在子文件夹src/pkg/code.google.com/p/go-tour
中。
检出源代码后,再次运行gotour
,它可以编译其必要的文件并使用该存储库中的静态文件为您提供本地的gotour。运行gotour
时,它应该会呈现类似以下内容:
2012/07/28 09:10:00 从C:\Go\src\pkg\code.google.com\p\go-tour提供内容
2012/07/28 09:10:00 在http://127.0.0.1:3999/提供服务
然后,您可以通过提供的地址浏览gotour。
顺便提一下,根据我理解的您的意思,您错过了这一点:您不需要在本地运行它。它只是您正在浏览的gotour网站,只是通过go get
获取的存储库在本地实例化。
英文:
The gotour
executable should already be provided by your go installation.
When you run gotour
without executing the instructed go get
prior, it should provide you with an import error.
2012/07/28 09:10:18 Couldn't find tour files: import "code.google.com/p/go-tour/": cannot find package
Running go get
will get the source - in this case from code.google.com/p/go-tour
- and place it into your active go environments source folders, in your case GOROOT="/usr/lib/go"
(, if no GOPATH
is set). The source will be placed in the subfolder src/pkg/code.google.com/p/go-tour
.
With the source checked out, running gotour
again, it can compile its necessary files and use the static files from that repository to serve you the gotour locally. When running gotour
it should present you with something like
2012/07/28 09:10:00 Serving content from C:\Go\src\pkg\code.google.com\p\go-tour
2012/07/28 09:10:00 Serving at http://127.0.0.1:3999/
You can then browse the gotour via the address provided.
As a side-note, as as I understood you, you missed this: You don’t need to run it locally. It is merely the gotour website you are browsing, just instantiated locally, though the repository you got via go get
.
答案3
得分: 1
输入:$GOPATH/bin/gotour
就能实现你想要的功能。
英文:
Typing: $GOPATH/bin/gotour
does exactly what you want.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论