使用专用git存储库时,您的工作空间的结构 [英] Structure for your go workspace when using private git repository

查看:113
本文介绍了使用专用git存储库时,您的工作空间的结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我可以看看<$ c是什么, $ c> go获取在获取github项目时起作用,但假设我自己的git项目没有 {github.com} / {username} / {projectname} > > p>

当你使用你自己的git私有仓库时,你应该使用什么布局和 git get url?

解决方案

这个包本身并没有引用它的存储位置。您只有:

 包mypackage 

因此,您可以在您自己的结构中使用本地版本,正如Volker在其评论中指出的那样。这是您在自己的项目中使用的导入路径:

  importmy / custom / path / mypackage

然后你可以打开它的源代码并将 mypackage 放到GitHub上。这将允许其他人通过 go get 命令获得它,但它们将使用 github.com import :

  importgithub.com/myuser/mypackage

除非您想要导入 my / custom / path / mypackage 即可。在这种情况下,您应该考虑重构您的路径,以便您使用与包的用户相同的github导入路径。


Ive been trying to work out what the standard folder layout/structure for go code/workspaces when you are not using github.

I can see how go get works when fetching github projects, but assumedly my own git projects would not have the {github.com}/{username}/{projectname} structure that is referenced by go get and how is structed on disk after you do go get

What layout and git get url should you have when using your own git private repositories?

解决方案

The package in itself carries no reference to where it is stored. You only have:

package mypackage

So, you can have your local version in your own structure, as Volker pointed out in his comment. This is the import path you use in your own projects:

import "my/custom/path/mypackage"

Then you can open source it and put mypackage onto GitHub. This will allow everyone else to get it with the go get command, but they will be using the github.com import:

import "github.com/myuser/mypackage"

This works perfectly fine unless you want to open-source packages which imports my/custom/path/mypackage. In such a case, you should consider restructuring your paths so that you use the same github import paths as the users of your package does.

这篇关于使用专用git存储库时,您的工作空间的结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆