为什么我安装后的GOPATH/src目录中只包含少量目录?

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

Wy my GOPATH/src contains few directories just after installed?

问题

我刚刚在我的机器上安装了Golang,并设置了GOPATH。
但是当我导航到我的go/src目录时,我发现src文件夹包含./sourcegraph.com./golang.org./github.com。此外,GOPATH/binGOPATH/pkg也不是空的。
所以我有几个问题:

1)我知道如何使用./github.com文件夹将我的代码推送到github,但为什么它默认包含一些不属于我自己的项目,比如acroca、cweil...等等?我可以清空这个文件夹吗?

2)我应该如何处理golang.org文件夹,可以删除它吗?

3)我应该如何处理sourcegraph.com文件夹,可以删除它吗?

4)我可以清空预安装的二进制文件和包的binpkg文件夹吗?

英文:

I've just installed Golang on my machine, and I set up GOPATH.
But when I navigate to my go/src I see that src folder contains ./sourcegraph.com, ./golang.org and ./github.com. Also GOPATH/bin and GOPATH/pkg also no empty.
So I have several questions:

  1. I know how to use ./github.com folder for pushing my code to github, but why it contains , from box, some other not mine projects inside such as acroca, cweil ... and other ? Can I clear this folder?

  2. What I should do with golang.org folder, can I remove it ?

  3. What I should do with sourcegraph.com folder, can I remove it ?

  4. Can I clear bin and pkg from preinstalled binaries and packages?

答案1

得分: 2

我认为你不仅安装了Golang,还安装/配置了带有Go扩展的Visual Studio Code IDE。当扩展安装所需的工具时,这些“外来”存储库会被创建。可以在这里找到工具的完整列表。或者可能是其他依赖于这些工具的类似IDE/扩展。

  1. 是的,你可以清除这些源代码,因为IDE仅依赖于编译后的二进制文件,源代码只在编译过程中需要。
  2. 与(1)相同。参考Golang子存储库
  3. 与(1)相同。
  4. 目前,你可以清除pkg目录的内容,但不要删除该目录。将来,当你安装一些包/库时,编译版本可能会在这些目录下创建,所以不要删除它。对于bin目录,不要删除其中的文件,因为IDE(Go扩展)依赖于它们。

但是,由于我不知道你还做了什么,我认为在完全删除它们之前,你可以尝试将它们移出你的GOPATH或备份一下,看看你的“开发环境”是否按预期工作。

英文:

I think you not only installed the Golang but also install/configure Visual Studio Code IDE with Go Extension. Those alien repositories were created when the extension installs needed tools. The full list of tools can be found here. Or probably other similar IDE/extension which depends on those tools.

  1. Yes you can clear the sources, since the IDE depends only on the compiled binary, and the sources are only needed during compilation.
  2. Same as (1). Refers to Golang SubRepositories
  3. Same as (1)
  4. For now, you can clear the content of pkg directory but don't remove the directory. In the future, when you install some packages/libraries, the compiled version may be created under the directories, so don't remove it. For bin directory, don't remove the files inside it, because the IDE (Go Extension) depends on them.

But, since I don't know exactly what else you've done, I think before you completely remove them, try just to move them outside your GOPATH or take a backup and see whether your dev environment works as expected.

huangapple
  • 本文由 发表于 2017年6月11日 18:17:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/44482683.html
匿名

发表评论

匿名网友

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

确定