Golang可以从私有的Subversion仓库导入包吗?

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

Can golang import package from private subversion repository?

问题

正如我们所知,Golang支持从著名的代码托管网站(如github、google code等)导入包,但我想弄清楚的是,Golang是否支持从我的私有subversion/git仓库导入包?如果Golang支持这一点,那么在项目之间共享一些常用的包将变得更加容易。

一个理想的例子:

package main

import "192.168.12.13/trunk/share/foolib"

func main() {
   ....
   foolib.xxxx...
}
英文:

As we know golang support import package from famous code hosted sites, such as github,google code and so on, but what I would like to figure out is whether golang support import package from my private subversion/git repository? It would become easier to share some common package among projects if golang support this.

an ideal example:

package main

import "192.168.12.13/trunk/share/foolib"

func main() {
   ....
   foolib.xxxx...
}

答案1

得分: 6

是的,您可以从私有存储库导入代码,请运行go help importpath获取说明。

然而,这是一个两阶段的过程:首先获取代码,然后将其编译到您的项目中。

您的示例表明您想要导入远程代码(因此,基本上是一个一阶段的过程),我怀疑这是不可能的。

英文:

yes, you can import code from private repositories, run go help importpath for instructions.

this is, however, a two phase approach: first get the code, than compile it into your project.

your example suggests that you want to import remote code (so, a one phase process essentially), I doubt that is possible

答案2

得分: 2

如果这是一个私有仓库,你最好手动管理。

对于Subversion,请使用Subversion外部;对于Git,请使用子模块等。

go get ... 是一个有用的工具,但是一旦你开始使用闭源签名的内部仓库,你可能会遇到困难;因为大多数非愚蠢的源代码控制已经支持这种类型的“子模块”功能,你最好使用你所使用的源代码控制工具的功能,并将自定义子模块导入到你的“src”目录中,然后,如上所述,使用以下方式导入:

import mylib "modules/xxx/trunk/src/blah"

而不是试图让go get一直做所有的事情。

英文:

If it's a private repository, you're almost certainly better off managing this manually.

For subversion use a subversion external; for git use a submodule, etc.

go get ...

Is a helpful tool, but you'll probably run into difficulty once you start using closed signed internal repositories; since most non-stupid source control already supports this type of 'submodule' like functionality, you're probably better off using the facilities of whatever source control you use and importing your custom submodules into your 'src' directory, and then, as above, importing using:

import mylib "modules/xxx/trunk/src/blah" 

...rather than trying to force go get to do all the things all of the time.

huangapple
  • 本文由 发表于 2012年10月24日 16:26:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/13045410.html
匿名

发表评论

匿名网友

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

确定