安装godoc之后修改了GOPATH,现在我需要在我的GOPATH中放入它所需的内容吗?

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

Installed godoc after altering GOPATH, now do I need what it put in my GOPATH?

问题

在按照教程操作时,当要求我运行godoc时,出现了问题,它找不到。

经过一番搜索,我发现:

  • godoc在1.2版本中已经更改,成为了一个独立的库和二进制文件。
  • 你必须通过"go get"来获取它,但没有设置GOPATH是行不通的。
  • 二进制安装似乎包含了godoc?我是从源代码安装的,所以默认情况下不包含它。

我将GOPATH导出到了当前应用程序路径/home/me/go_project/test。GOROOT已经设置好了。(注意:GOPATH不喜欢与GOROOT设置为相同)

之后,我运行了"go get code.google.com/p/go.tools/cmd/godoc",它将二进制文件安装到了我的GOROOT/bin目录下(太好了!)

它还在我的/home/me/go_project/test/src/code.google.com/p...下创建了一个pkg安装目录(嗯...是什么?)

我真的不需要在我的测试应用程序下保留那个code.google...的部分;Go是否需要保留它?它不会改变库路径、依赖关系或其他任何东西,对吗?

基本上...我可以只使用它放在GOROOT/bin下的二进制文件,并删除它放在我的go_project应用程序目录下的东西,而不会影响Go吗?

英文:

While following a tutorial I hit a wall when it wanted me to run godoc. It was missing.

After a bit of searching around, I discovered:

  • godoc has been changed for 1.2, so it's a separate library and
    binary.
  • You have to get it through "go get", which won't work without
    GOPATH.
  • Binary installations apparently include godoc? I installed
    from source, so it's not included by default.

I exported a GOPATH to my current application path /home/me/go_project/test. GOROOT was already set. (Note: GOPATH doesn't like to be set the same as GOROOT)

After that I ran "go get code.google.com/p/go.tools/cmd/godoc" and it dutifully installed the binary into my GOROOT/bin (yay!)

It also created a pkg installation under my /home/me/go_project/test/src/code.google.com/p... (Um...wat?)

I really don't need that code.google... bit under my test application; is there any reason Go would need that kept there? It doesn't alter anything in library paths or dependencies or anything, does it?

Essentially...can I just use the binary it put in GOROOT/bin and erase the stuff it put under my go_project application directory without affecting Go?

答案1

得分: 1

是的,Go二进制文件是静态链接的(几乎是的)。你可以只使用GOROOT/bin目录下的二进制文件,而不会影响Go,可以删除go_project应用程序目录下的内容。

英文:

> Essentially...can I just use the binary it put in GOROOT/bin and erase the stuff it put under my > go_project application directory without affecting Go?

Yes. Go binaries are statically linked (almost).

答案2

得分: 0

你的问题的答案是肯定的。然而,如果你计划进行大量的Go开发,最终你会想要设置一个GOPATH。更新Godoc到新版本将需要它。任何你可能需要的开发工作的包最好安装到GOPATH中。

我建议你果断行动,设置一个GOPATH。

英文:

Tbe answer to your question is yes. However if you plan on doing much Go dev you are going to want to setup a GOPATH eventually. Updating Godoc to a new version will need it. Any packages you might want for your dev work will be best installed into a GOPATH.

I would just bite the bullet and set one up.

huangapple
  • 本文由 发表于 2014年2月25日 03:43:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/21997425.html
匿名

发表评论

匿名网友

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

确定